5

I am having troubles setting up the style of selected item in metro app list box.

I have created the DataTemplate for the item in which there is a TextBlock which colour I would like to change. I tried many things from WPF but they are not available for metro like 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 didn't know what to change to achieve what I want. The same was with value converter as I didn't know how to use RelativeSource to supply the converter with the IsSelected property of the ListBoxItem....

Thanks for help!

1 Answer 1

6

You're exactly right to change the ItemContainerStyle. If you're in Visual Studio or Blend, right click on the ListView and select

Edit Additional Templates -> Edit Generated Item Container [ItemContainerStyle] -> Edit a Copy

It's important when doing this that 'Edit Current' is not enabled. If it is, find that template and delete it (it might be an empty template and you want the full template).

This will create a style for a ListViewItem. The ListViewItem has a lot of controls within it and most of them deal with Selection or other states. You'll want to make changes to the Selected VisualState.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.