I am trying to recreate the Mail UI from Windows 8 in a WPF application running on Windows 7. Here's what I want to achieve:
In particular, I don't know how to change the background color for selected items e.g. the Inbox item in the first column and the mail from Twitter in the second column. I have tried several solutions from other similar Stackoverflow Questions but none seem to work for me. e.g.
Selected item loses style when focus moved out in WPF ListBox
WPF ListView Inactive Selection Color
Here is the code I have for my listview:
<ListView Grid.Row="0" SelectedItem="{Binding Path=SelectedArea}" ItemsSource="{Binding Path=Areas}" Background="#DCE3E5" >
<ListView.Resources>
<!-- Template that is used upon selection of an Area -->
<ControlTemplate x:Key="SelectedTemplate" TargetType="ListViewItem">
<Border Background="#388095" Cursor="Hand" >
<TextBlock Text="{Binding Name}" Margin="5" />
</Border>
</ControlTemplate>
<Style TargetType="ListViewItem">
<Setter Property="Template">
<Setter.Value>
<!-- Base Template that is replaced upon selection -->
<ControlTemplate TargetType="ListViewItem">
<Border Background="#DCE3E5" Cursor="Hand" >
<TextBlock Text="{Binding Name}" Margin="5" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="true" />
</MultiTrigger.Conditions>
<Setter Property="Template" Value="{StaticResource SelectedTemplate}" />
</MultiTrigger>
</Style.Triggers>
</Style>
</ListView.Resources>
</ListView>
How can I change the background color of the selected item? And how do I retain the color change when the focus changes.