I programmatically fill my listview with Strings using a foreach statement without using .itemssource and then i created this style trigger (which appears to be correct)
<ListView.Resources>
<Style TargetType="ListViewItem">
<Setter Property="IsSelected" Value="True" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Green"/>
</Trigger>
</Style.Triggers>
</Style>
</ListView.Resources>
And then i run the project and click on a list view item… and the background is blue ……..
I’m Just wondering if style triggers require the use of databinding… or if my trigger is wrong.. or if anyone has any ideas.. ???
Your problem is not related to binding, and the Trigger is also OK, except that it will be ineffective.
The background color of a selected ListViewItem is set by the VisualStateManager in the ListViewItem’s ControlTemplate like show in the MSDN example:
No matter to what value you set the item’s background, it will be set to the value of
{StaticResource SelectedBackgroundColor}when the item’s state isSelected. You might however add the following lines to your ListViewItem style to override the value of the SelectedBackgroundColor resource: