在造型的ListView的SelectedItem在Metro应用程序XAML [英] Styling SelectedItem in ListView in Metro App XAML

查看:179
本文介绍了在造型的ListView的SelectedItem在Metro应用程序XAML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有麻烦设置所选项目的风格的地铁应用程序列表框中。

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

我创建了DataTemplate中的项目,其中有我想改变的颜色一个TextBlock。我试过很多东西从WPF但不适用于像DataTemplate.Triggers,Style.Triggers等地铁。我也试图使ItemContainerStyle模板的副本,但因为它使用的内容presenter显示我的DataTemplate我不知道该怎么改,以达到我想要的。同样是与值转换器,因为我不知道如何使用的RelativeSource与ListBoxItem的....

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....

感谢您的帮助!

推荐答案

您说得对极了改变ItemContainerStyle。如果您在Visual Studio或混合是,右击ListView和选择

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

编辑附加模板 - >编辑生成的项容器[ItemContainerStyle] - >编辑复制

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).

这将创建一个ListViewItem的风格。该ListViewItem的有很多在它的控制,大部分处理或选择其他国家。您将要进行更改的VisualState。

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.

这篇关于在造型的ListView的SelectedItem在Metro应用程序XAML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆