1

I have below code in my App.xaml to override pivot item header color

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

i want to set differernt PivotHeaderForegroundSelectedBrush for different Pivot e.g Pivote1 ->pivoteItem1 -> PivotHeaderForegroundSelectedBrush should be RED

Pivote1 ->pivoteItem2 -> PivotHeaderForegroundSelectedBrush should be RED

Pivote2 ->pivoteItem1 -> PivotHeaderForegroundSelectedBrush should be GREEN

Pivote2 ->pivoteItem2 -> PivotHeaderForegroundSelectedBrush should be GREEN

I tried to override this color theme in Page but it is not working

if i set below style to pivote it changes color but for both Selected and unselected , it there any way to do this for only selected

    <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> 
Dattatray Deokar
  • 1,923
  • 2
  • 21
  • 31

1 Answers1

1

You can't change it for a specific Pivot, only application-wide. It's a bug. You might be able to change it in code, though. See this thread.

Decade Moon
  • 32,968
  • 8
  • 81
  • 101
  • The only way to differentiate the selected and unselected colors is to override the `PivotHeaderForegroundUnselectedBrush` and `PivotHeaderForegroundSelectedBrush` resources in your application's resource dictionary, as you did. You can't override these resources per-pivot. It just won't work. – Decade Moon Nov 18 '14 at 13:24
  • hi Decade Moon, i have updated my question do you have suggestion on it? – Dattatray Deokar Nov 18 '14 at 13:24
  • See [my answer to this question](http://stackoverflow.com/a/26974421/734040) I did yesterday for more information. – Decade Moon Nov 18 '14 at 13:26
  • Is it possible to override values of resources from App.xml through c# code runtime? – Dattatray Deokar Nov 18 '14 at 13:51
  • Yes, you can access the resource dictionary through `Application.Current.Resources` and theme resources through `Application.Current.Resources.ThemeDictionaries`. You would have to dynamically change the resources on page enter/exit so that pivot headers on different pages will get different colors. – Decade Moon Nov 18 '14 at 14:06