Reputation: 23
I want to change the Color of a Listview Row in XAML when I:
I tried many different Solutions I found here in the Forum and also on other websides, but I never found a solution that really changed any of the Color. I just get it to Change the text Color when I select a Item but thats not what I want. Maybe someone can help me, this is my 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>
Upvotes: 1
Views: 931
Reputation: 169150
You could define an 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>
Upvotes: 4