How do I change text color on the selected row inside a ListView/GridView? (using Expression Dark th
- by Thiado de Arruda
I'm using theExpression Dark WPF Theme(http://wpfthemes.codeplex.com/) with a ListView(view property set to a GridView) to display some user data like the following :
<ListView
Grid.Row="1"
ItemsSource="{Binding RegisteredUsers}"
SelectedItem="{Binding SelectedUser}"
>
<ListView.View>
<GridView>
<GridViewColumn
Header="Login"
DisplayMemberBinding="{Binding Login}"
Width="60"/>
<GridViewColumn
Header="Full Name"
DisplayMemberBinding="{Binding FullName}"
Width="180"/>
<GridViewColumn
Header="Last logon"
DisplayMemberBinding="{Binding LastLogon}"
Width="120"/>
<GridViewColumn
Header="Photo"
Width="50">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Image
Source="{Binding Photo}"
Width="30"
Height="35"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
The rows have white text with a dark background and white background when selected, however the text color doesnt change when selected and it makes very difficult to read, I would like the text to have a dark color when the row is selected. I have searched for a way to style the text color but with no success, here is the control template for the ListViewItem :
<Border SnapsToDevicePixels="true" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2" x:Name="border">
<Grid Margin="2,0,2,0">
<Rectangle x:Name="Background" IsHitTestVisible="False" Opacity="0.25" Fill="{StaticResource NormalBrush}" RadiusX="1" RadiusY="1"/>
<Rectangle x:Name="HoverRectangle" IsHitTestVisible="False" Opacity="0" Fill="{StaticResource NormalBrush}" RadiusX="1" RadiusY="1"/>
<Rectangle x:Name="SelectedRectangle" IsHitTestVisible="False" Opacity="0" Fill="{StaticResource SelectedBackgroundBrush}" RadiusX="1" RadiusY="1"/>
<GridViewRowPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="0,2,0,2" VerticalAlignment="Stretch" />
</Grid>
</Border>
The trigger that changes the background color simply applies an animation to change the 'SelectedRectangle' opacity, but I cant change the text color on the same trigger(I tried using a setter for the foreground color on the ListViewItem, but with no success).
Does someone have a clue on that?