我希望在I:
时更改XAML中Listview行的颜色我尝试了很多不同的解决方案,我在论坛和其他网站上找到了这些解决方案,但我从来没有找到真正改变任何颜色的解决方案。我只是在选择项目时更改文本颜色,但这不是我想要的。 也许有人可以帮助我,这是我的XAML Listview:
<ListView ItemsSource="{Binding Files}" x:Name="listBox2" Margin="269,32,10.286,0" Height="119" VerticalAlignment="Top" Drop="DropEvent" AllowDrop="True">
<ListView.View>
<GridView>
<GridViewColumn
DisplayMemberBinding="{Binding Path}"
Width ="1000"/>
</GridView>
</ListView.View>
</ListView>
</ListView>
答案 0 :(得分:3)
您可以定义ItemContainerStyle
:
<ListView ItemsSource="{Binding Files}" x:Name="listBox2">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding}" Width="1000"/>
</GridView>
</ListView.View>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Green" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
</ListView>