Styling SelectedItem in ListView in Metro XAML Application

I'm having trouble adjusting the style of the selected item in the Metro app list.

I created a DataTemplate for an element that has a TextBlock whose color I would like to change. I tried many things from WPF, but they are not available for the metro, such as DataTemplate.Triggers, Style.Triggers and so on. I also tried to make a copy of the ItemContainerStyle template, but since it uses ContentPresenter to display my DataTemplate, I did not know what to change in order to achieve what I want. The same thing happened with the value converter, since I did not know how to use the RelativeSource to supply the converter with the IsSelected ListBoxItem property ....

Thanks for the help!

+5
source share
1 answer

You are absolutely right to change ItemContainerStyle. If you are in Visual Studio or Blend, right-click on the ListView and select

Change additional templates → Edit created container of elements [ItemContainerStyle] → Change copy

It is important that the "Edit Current" is not turned on. If so, find this template and delete it (it may be an empty template and you need a full template).

This will create a style for the ListViewItem. ListViewItem has many controls inside it, and most of them deal with Selection or other states. You will want to make changes to SelectedVisualState.

+6
source

All Articles