无法在 WinRT 中使用 ListView.ItemContainerStyle 设置 ListViewItem.IsSelected
Cannot set ListViewItem.IsSelected using ListView.ItemContainerStyle in WinRT
正在尝试将 Selected 属性 的所有项目设置为 TRUE 在多 Select 模式 ListView 上。我想我的语法是正确的。有什么问题的猜测吗?
<ListView x:Name="myListView" SelectionMode="Multiple" BorderThickness="1"
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<Image Source="{Binding Thumbnail}"/>
<TextBlock Text="{Binding dataSource.Name}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="IsSelected" Value="True" />
</Style>
</ListView.ItemContainerStyle>
</ListView>
事实证明这在 WINRT 中是不可能的
找到解决方法 @ http://pmichaels.net/2014/09/18/binding-isselected-method-in-the-listview-control-in-winrt/
我已经在评论中回答了你的另一个问题,但仍然如此。
遗憾的是,WinRT 中的 Setters 不支持绑定。我认为 Silverlight 仅在版本 5 中提供了它们。对于解决方法,您基本上可以定义一个附加的依赖项 属性 来为您设置绑定。你可以在这里看看:here
希望对您有所帮助!
正在尝试将 Selected 属性 的所有项目设置为 TRUE 在多 Select 模式 ListView 上。我想我的语法是正确的。有什么问题的猜测吗?
<ListView x:Name="myListView" SelectionMode="Multiple" BorderThickness="1"
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<Image Source="{Binding Thumbnail}"/>
<TextBlock Text="{Binding dataSource.Name}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="IsSelected" Value="True" />
</Style>
</ListView.ItemContainerStyle>
</ListView>
事实证明这在 WINRT 中是不可能的
找到解决方法 @ http://pmichaels.net/2014/09/18/binding-isselected-method-in-the-listview-control-in-winrt/
我已经在评论中回答了你的另一个问题,但仍然如此。
遗憾的是,WinRT 中的 Setters 不支持绑定。我认为 Silverlight 仅在版本 5 中提供了它们。对于解决方法,您基本上可以定义一个附加的依赖项 属性 来为您设置绑定。你可以在这里看看:here
希望对您有所帮助!