ListView.ItemContainerStyle IsSelected属性似乎并没有影响到WinRT的选择 [英] ListView.ItemContainerStyle IsSelected property does not seem to affect selection on WinRT

查看:127
本文介绍了ListView.ItemContainerStyle IsSelected属性似乎并没有影响到WinRT的选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是想一个问题,调试过程中使用IsSelected直接设置为true(W / O绑定)(最后我想使用绑定,但发现即使W / O绑定这不起作用)。



下面的代码工作正常WPF(选定的所有项目),但在WinRT中不起作用(执行后没有选择的项目)。



这是一个bug /功能吗?



下面的XAML将在WPF窗口和WinRT的页面。

$ b编译
$ b

 < ListView控件的SelectionMode =多的Horizo​​ntalAlignment =拉伸> 
< 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属性=Horizo​​ntalContentAlignmentVALUE =弹力/>
< 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆