【发布时间】:2016-02-02 18:47:48
【问题描述】:
我使用ListView 和WrapPanel 作为它的ItemsPanel。我需要更改所选项目的样式 - 使用不同的背景颜色并在所选项目周围添加边框,就像 Windows 7 的资源管理器一样。
<ListView ItemsSource="{Binding Items}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" Margin="10">
<Rectangle Width="100" Height="100" Fill="Pink" />
<TextBlock Text="{Binding Caption}" Margin="0,10,0,0" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
【问题讨论】:
标签: c# .net wpf listview listviewitem