ListView.ItemContainerStyle IsSelected属性似乎并没有影响到WinRT的选择 [英] ListView.ItemContainerStyle IsSelected property does not seem to affect selection on WinRT
问题描述
我是想一个问题,调试过程中使用IsSelected直接设置为true(W / O绑定)(最后我想使用绑定,但发现即使W / O绑定这不起作用)。
下面的代码工作正常WPF(选定的所有项目),但在WinRT中不起作用(执行后没有选择的项目)。
这是一个bug /功能吗?
下面的XAML将在WPF窗口和WinRT的页面。
$ b编译$ b
< ListView控件的SelectionMode =多的HorizontalAlignment =拉伸>
< ListView.ItemContainerStyle>
<风格的TargetType =ListViewItem的>
< setter属性=IsSelectedVALUE =真/>
< /样式和GT;
< /ListView.ItemContainerStyle>
<文本框宽度=200/>
<文本框宽度=200/>
<文本框宽度=200/>
<文本框宽度=200/>
<文本框宽度=200/>
< /&的ListView GT;
您可以解决使用预定义的DataTemplate为ListViewItem的这个问题。希望这有助于
< ListView控件的SelectionMode =多>
< ListView.ItemContainerStyle>
<风格的TargetType =ListViewItem的>
< setter属性=HorizontalContentAlignmentVALUE =弹力/>
< setter属性=的ContentTemplate>
< Setter.Value>
<&DataTemplate的GT;
< ListViewItem的IsSelected =真>
<文本框高度=30WIDTH =200>< /文本框>
< / ListViewItem的>
< / DataTemplate中>
< /Setter.Value>
< /二传手>
< /样式和GT;
< /ListView.ItemContainerStyle>
<文本框/>
<文本框/>
<文本框/>
<文本框/>
<文本框/>
< /&的ListView GT;
I was trying to use IsSelected set directly to true (w/o binding) during debugging of an issue (at the end I am trying to use binding, but have found that even w/o binding this does not work).
The following code works fine in WPF (all items selected) but does not work on WinRT (no item selected after execution).
Is this a bug/feature?
The following XAML will compile in a WPF window and in a WinRT page..
<ListView SelectionMode="Multiple" HorizontalAlignment="Stretch">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="IsSelected" Value="True"/>
</Style>
</ListView.ItemContainerStyle>
<TextBox Width="200"/>
<TextBox Width="200"/>
<TextBox Width="200"/>
<TextBox Width="200"/>
<TextBox Width="200"/>
</ListView>
You can solve this problem using predefined datatemplate for listviewItem.Hope this helps
<ListView SelectionMode="Multiple">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<ListViewItem IsSelected="True" >
<TextBox Height="30" Width="200" ></TextBox>
</ListViewItem>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
<TextBox />
<TextBox/>
<TextBox/>
<TextBox/>
<TextBox/>
</ListView>
这篇关于ListView.ItemContainerStyle IsSelected属性似乎并没有影响到WinRT的选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!