ppa*_*ojr 5 listview windows-8 windows-runtime c++-cx winrt-xaml
我有这个在代码中XAML显示一个.在将被用作一个选择菜单.ListViewC++/CXListView
<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>
Run Code Online (Sandbox Code Playgroud)
如下图所示,选择不会占据所有列,并在选中时显示复选标记.

有没有办法消除这种填充和复选标记?
Fil*_*kun 16
您需要在Blend中打开视图,然后右键单击列表并选择"编辑其他模板"/"编辑生成的项目容器(ItemContainerStyle)"/"编辑副本".然后,你可以编辑Style为ListViewItem通过生成的ListView时候,填入您的项目.在左侧的"状态"选项卡中,您可以看到使用的状态ListViewItem.当您选择其中一个时 - 设计图面显示ListViewItem在该状态下的样子,并且它还切换到记录模式,您可以在其中定义模板的各种元素属性的属性值.然后,您可以查看哪些元素受到可视状态动画的影响,并修改这些动画或删除元素本身.如果你在Blend中删除元素-所有相关的可视状态的动画将被自动删除,所以你的情况,你可以看到,在SelectionStates VisualStatesGroup该Selected状态改变的SelectionBackground元素Opacity为1.您可以修改该目标Opacity在它用于修改所有国家价值另一个所需的值或只是SelectionBackground通过在"对象和时间轴"面板中选择它来删除元素(它实际上将从模板中删除所有状态并删除所有影响它的动画).然后你可能同样想要删除HintGlyphBorder, SelectingGlyph, SelectedCheckMarkOuter.
要删除填充 - 请确保通过单击微小的红色记录按钮或将"状态"选项卡中当前显示的状态切换回"基准"来禁用状态记录,然后在"属性"中选择ContentBorder并更改它Margin选项卡到0,0,0,0并执行相同操作SelectedBorder.
这是Blend的带注释的截图:

| 归档时间: |
|
| 查看次数: |
4730 次 |
| 最近记录: |