Xaml 如何为多个数据透视设置不同的选定/未选定数据透视标题颜色
我在App.xaml中有以下代码来覆盖透视项目标题颜色Xaml 如何为多个数据透视设置不同的选定/未选定数据透视标题颜色,xaml,user-interface,windows-phone-8.1,Xaml,User Interface,Windows Phone 8.1,我在App.xaml中有以下代码来覆盖透视项目标题颜色 <Application.Resources> <ResourceDictionary> <ResourceDictionary.ThemeDictionaries> <ResourceDictionary x:Key="Default"> <SolidColorBrush x
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="PivotHeaderForegroundUnselectedBrush" Color="#CACACA"/>
<SolidColorBrush x:Key="PivotHeaderForegroundSelectedBrush" Color="#D81B60"/>
<SolidColorBrush x:Key="ButtonPressedForegroundThemeBrush" Color="Transparent" />
<ImageBrush x:Key="HubBackgroundImageBrush" ImageSource="Assets/Profile.png"/>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<ImageBrush x:Key="HubBackgroundImageBrush" ImageSource="{x:Null}"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Application.Resources>
我想为不同的轴设置不同的PivotHeaderForegroundSelectedBrush
例如
Pivot1->PivotItem1->PivotHeaderForeGroundSelected笔刷应为红色
Pivot1->PivotItem2->PivotHeaderForeGroundSelected笔刷应为红色
Pivote2->PivotItem1->PivotHeaderForeGroundSelected笔刷应为绿色
Pivote2->PivotItem2->PivotHeaderForeGroundSelected笔刷应为绿色
我试图在页面中覆盖此颜色主题,但它不起作用
若我将“下面的样式”设置为“旋转”,它会更改颜色,但对于选定和未选定,它并没有任何方法可以仅对选定对象执行此操作
<DataTemplate x:Key="PivotHeaderSelectedTemplate">
<TextBlock Margin="0,10,0,0"
Text="{Binding}"
FontFamily="Segoe UI"
FontStyle="Normal"
FontSize="44"
Foreground="#630083"/>
</DataTemplate>
<Style x:Key="PivotStyle"
TargetType="Pivot">
<Setter Property="HeaderTemplate"
Value="{StaticResource PivotHeaderSelectedTemplate}"/>
<Setter Property="Margin"
Value="0"/>
</Style>
您不能为特定轴更改它,只能在应用程序范围内更改。这是一只虫子。不过,您可以在代码中对其进行更改。请参阅。区分选定颜色和未选定颜色的唯一方法是覆盖应用程序资源字典中的PivotHeaderForegroundUnselectedBrush
和PivotHeaderForegroundSelectedBrush
资源。您不能覆盖每个枢轴的这些资源。这根本不起作用。嗨,我已经更新了我的问题。你对此有什么建议吗?有关更多信息,请参阅我昨天所做的。是否可以通过c#代码运行时覆盖App.xml中的资源值?是的,您可以通过Application.Current.Resources
访问资源字典,通过Application.Current.Resources.themedictionary
访问主题资源。您必须动态更改页面enter/exit上的资源,以便不同页面上的pivot标题将获得不同的颜色。Silverlight还是XAML?