在 MultiSelect ListView (UWP) 中隐藏默认复选框 [英] Hide Default checkbox inside MultiSelect ListView (UWP)

查看:32
本文介绍了在 MultiSelect ListView (UWP) 中隐藏默认复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的 ListView

I have a ListView like this

                            <ListView  ItemsSource="{x:Bind DDLItemsSource, Mode=OneWay}" Background="Transparent" VerticalAlignment="Stretch" 
                                   SelectionChanged="StudentsList_SelectionChanged" x:Name="StudentsList" SelectionMode="Multiple"  HorizontalAlignment="Stretch" >
                            <ListView.ItemContainerStyle>
                                <Style TargetType="ListViewItem">
                                    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                                    <Setter Property="BorderThickness" Value="0 0 0 1"/>
                                </Style>
                            </ListView.ItemContainerStyle>
                        </ListView>

当这个 Listview 在页面上呈现时,它在每个项目中都带有默认复选框.我想隐藏那些复选框并只显示数据.我怎样才能做到这一点?

When this Listview Renders on-page, it comes with Default Checkbox inside each item. I want to hide those Checkboxes and show only data. how can I achieve this?

这是 ListView 现在的样子

This is how the ListView looks now

推荐答案

在 MultiSelect ListView (UWP) 中隐藏默认复选框

Hide Default checkbox inside MultiSelect ListView (UWP)

通过编辑<Style TargetType="ListViewItem" x:Key="ListViewItemExpanded">,(在 generic.xaml 文件中)您可以找到复选框已创建使用MultiSelectSquare 边框,我们只需添加如下编辑Normal VisualState,当Multiple SelectionMode 时复选框将隐藏.

That could be approached easily by edit the <Style TargetType="ListViewItem" x:Key="ListViewItemExpanded">,(in generic.xaml file) you could find the checkbox was made with MultiSelectSquare Border, we just add the edit Normal VisualState like the following, and the checkbox will be hidden when Multiple SelectionMode.

<VisualState x:Name="Normal">
    <Storyboard>
        <PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter" />
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectSquare" Storyboard.TargetProperty="Visibility">
            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
        </ObjectAnimationUsingKeyFrames>
    </Storyboard>
</VisualState>

使用

<ListView
    Name="TestList"
    IsItemClickEnabled="True"
    ItemClick="ListView_ItemClick"
    ItemContainerStyle="{StaticResource ListViewItemExpanded}"
    SelectionMode="Multiple"
    Visibility="Visible"
    >

这篇关于在 MultiSelect ListView (UWP) 中隐藏默认复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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