Styling SelectedItem in ListView in Metro App XAML

☆樱花仙子☆ 提交于 2019-12-21 16:57:52

问题


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:


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.



来源:https://stackoverflow.com/questions/12150683/styling-selecteditem-in-listview-in-metro-app-xaml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!