列表视图选择显示不带填充和不勾选 [英] Listview selection display with no padding and no checkmark

查看:230
本文介绍了列表视图选择显示不带填充和不勾选的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的 XAML 来显示的ListView C ++ / CX code。在的ListView 将被用来作为一个选择菜单。

I have this XAML to display a ListView in a C++/CX code. The ListView will be used as a selection menu.

<ListView x:Name="itemsListView"
 ItemsSource="{Binding Source={StaticResource MenuDataSourceCVS}}"
 HorizontalAlignment="Stretch"
 Width="230"
 Margin="0,45,0,0"
 VerticalAlignment="Top"
 Grid.Row="1"
 SelectionChanged="itemsListView_SelectionChanged" SelectionMode="Single"
 HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
 FontFamily="Global User Interface">
 <ListView.ItemTemplate>
    <DataTemplate>
        <StackPanel Orientation="Horizontal" Height="40" Width="230">
            <TextBlock Text="{Binding Name}"
                Margin="10,5" Width="150" Height="30"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"/>
            <Border Height="30" Width="30" Margin="5">
                <Image Source="{Binding ImageSrc}" Stretch="Fill"/>
            </Border>
        </StackPanel>
    </DataTemplate>
 </ListView.ItemTemplate>
</ListView>

正如你在图中波纹管的选择看不占所有列在选中时显示复选标记。

As you can see in the figure bellow the selection does not occupy all the column and displays a checkmark when selected.

有没有办法消除这种填充和对号的方法?

Is there a way to eliminate this padding and the checkmark?

推荐答案

您需要打开在Blend你的看法,然后用鼠标右键单击列表,然后选择编辑其他模板/编辑生成的项容器(ItemContainerStyle)/编辑复制。然后,你可以编辑风格的由 ListView控件生成 ListViewItem的 时,填入您的物品。在左侧的状态选项卡中可以看到由 ListViewItem的中使用的状态。当您选择其中之一 - 设计图面显示什么ListViewItem的样子在这种状态下,它也切换到拍摄模式,您可以定义模板的各种元素属性的属性值。然后你就可以看到哪些元素是由视觉状态的动画受到影响,要么修改这些动画或删除元素本身。如果您在Blend中删除元素 - 所有相关的可视​​状态的动画将被自动删除,所以你的情况,你可以看到,在 SelectionStates VisualStatesGroup 状态改变了 selectionBackground已元素的透明度 1。你可以修改目标透明度它修改到另一个期望值或直接删除所有状态值 selectionBackground已通过在对象和时间线面板中选择元素(它实际上从模板的所有国家将其删除,并删除它影响所有动画)。那么你可能同样希望删除 HintGlyphBorder,SelectingGlyph,SelectedCheckMarkOuter

You need to open your view in Blend, then right click the list and select "Edit Additional Templates"/"Edit Generated Item Container (ItemContainerStyle)"/"Edit a Copy". Then you can edit the Style for the ListViewItem generated by the ListView when it is populated with your items. In the "States" tab on the left you can see the states used by the ListViewItem. When you select one of them - the design surface shows what the ListViewItem looks like in that state and it also switches to recording mode where you can define the property values of various element properties of the template. Then you can see which elements are affected by visual state animations and either modify these animations or remove the elements themselves. If you remove an element in Blend - all related visual state animations will be deleted automatically, so in your case you can see that in the SelectionStates VisualStatesGroup the Selected state changes the SelectionBackground element's Opacity to 1. You can either modify that target Opacity value in all states that modify it to another desired value or simply remove the SelectionBackground element by selecting it in the "Objects and Timeline" panel (it will actually remove it from the template for all states and remove all animations that affect it). Then you may similarly want to remove HintGlyphBorder, SelectingGlyph, SelectedCheckMarkOuter.

要移除填充 - 确保通过单击微小的红色录音按钮或开关在状态选项卡中的当前显示的状态恢复为基地禁用状态记录,然后选择 ContentBorder 并更改其保证金中的属性选项卡0,0,0,0和做同样为 SelectedBorder

To remove the padding - make sure to disable recording for the state either by clicking the tiny red recording button or by switching the currently displayed state in the "States" tab back to "Base", then select ContentBorder and change its Margin in the "Properties" tab to 0,0,0,0 and do the same for SelectedBorder.

下面是从混合的注释截图:

Here's an annotated screenshot from Blend:

这篇关于列表视图选择显示不带填充和不勾选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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