2
votes

I am working on Pivot Control in Windows Phone 8.1 I Set foreground Property of pivotitem Header to Red Color it is working Fine but,I set all items header to Red Color and the Opacity of the Item Header Never Changes of UnFocused PivotItem cloud Please Help me how to solve this
Problem. Here is the code

   <Pivot Title="Pivot Title" >
        <PivotItem >
            <PivotItem.Header >
                <TextBlock Text="One" Foreground="Red" FontSize="48"/>
            </PivotItem.Header>
        </PivotItem>
        <PivotItem>
            <PivotItem.Header>
                <TextBlock Text="two" Foreground="Red" FontSize="48"/>
            </PivotItem.Header>
        </PivotItem>
        <PivotItem>
            <PivotItem.Header>
                <TextBlock Text="three" Foreground="Red" FontSize="48"/>
            </PivotItem.Header>
        </PivotItem>
    </Pivot>
2
You mean the header Color of the pivot items which are not focused is not getting changed?Kulasangar
Yes If i dont set Any Forground Color it is working Fine when i change the forground color it was not workingHarish Kinthali

2 Answers

6
votes

The Default Styles Should be over ridden in Resource Dictionary <ResourceDictionary.ThemeDictionaries> <ResourceDictionary x:Key="Default"> <SolidColorBrush x:Key="PivotHeaderForegroundUnselectedBrush" Color="#AFAFAF" /> <SolidColorBrush x:Key="PivotHeaderForegroundSelectedBrush" Color="#56C5FF" /> </ResourceDictionary> </ResourceDictionary.ThemeDictionaries>

-1
votes

I guess you'll need to set a different VisualState for either the Selected or Unselected state.

Have a look over here How to Change Pivot Header Template in Windows Phone 8

Or you could use the SelectionChanged event handler for your pivot:

private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (e.AddedItems.Count > 0)
    {
        PivotItem currentItem = e.AddedItems[0] as PivotItem;

        if (currentItem != null)
        {
            (currentItem.Header as TextBlock).Foreground = new SolidColorBrush(Colors.White);
        }
    }

    if (e.RemovedItems.Count > 0)
    {
        PivotItem currentItem = e.RemovedItems[0] as PivotItem;

        if (currentItem != null)
        {
            (currentItem.Header as TextBlock).Foreground = new SolidColorBrush(Colors.Red);
        }
    }
}

Hope it helps!