Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unfortunately there is a lot of styling that needs to happen to get this accomplished. First you need to create a style for the Pivot. It is best to do this with Expression Blend.</p> <pre><code>&lt;Style x:Key="PivotStyle1" TargetType="controls:Pivot"&gt; &lt;Setter Property="Margin" Value="0"/&gt; &lt;Setter Property="Padding" Value="0"/&gt; &lt;Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/&gt; &lt;Setter Property="Background" Value="Transparent"/&gt; &lt;Setter Property="ItemsPanel"&gt; &lt;Setter.Value&gt; &lt;ItemsPanelTemplate&gt; &lt;Grid/&gt; &lt;/ItemsPanelTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="controls:Pivot"&gt; &lt;Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition Height="*"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;Grid Background="{TemplateBinding Background}" CacheMode="BitmapCache" Grid.RowSpan="3"/&gt; &lt;ContentPresenter ContentTemplate="{TemplateBinding TitleTemplate}" Content="{TemplateBinding Title}" Margin="24,17,0,-7"/&gt; &lt;controlsPrimitives:PivotHeadersControl x:Name="HeadersListElement" Grid.Row="1"/&gt; &lt;ItemsPresenter x:Name="PivotItemPresenter" Margin="{TemplateBinding Padding}" Grid.Row="2"/&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>Notice in the style that there is a <code>PivotHeadersControl</code> in it. This control is a TemplatedItemsControl of type <code>PivotHeaderItem</code>. This PivotHeaderItem is what we need to style. You can set the <code>ItemContainerStyle</code> property to alter how the headers will look depending on their state.</p> <pre><code>&lt;Style x:Key="PivotHeaderItemStyle1" TargetType="controlsPrimitives:PivotHeaderItem"&gt; &lt;Setter Property="Background" Value="Transparent"/&gt; &lt;Setter Property="Padding" Value="21,0,1,0"/&gt; &lt;Setter Property="CacheMode" Value="BitmapCache"/&gt; &lt;Setter Property="Margin" Value="0"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="controlsPrimitives:PivotHeaderItem"&gt; &lt;Grid&gt; &lt;VisualStateManager.VisualStateGroups&gt; &lt;VisualStateGroup x:Name="SelectionStates"&gt; &lt;VisualState x:Name="Unselected"&gt; &lt;Storyboard&gt; &lt;ColorAnimation Duration="0" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" To="Gray"/&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="Selected"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="contentPresenter"/&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;/VisualStateManager.VisualStateGroups&gt; &lt;TextBlock x:Name="contentPresenter" Text="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Foreground="{StaticResource PhoneAccentBrush}" Margin="{TemplateBinding Padding}" Opacity=".4"/&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>I've modified the default style to have a TextBlock instead of a ContentPresenter. This allows you to set the foreground from the Unselected state storyboard. </p> <p>Make sure that you set the Style of the Pivot to be PivotStyle1 and that the ItemContainerStyle of the PivotHeadersControl is set to PivotHeaderItemStyle1. You'll also need to modify it a little to get the sizing back the way you want it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload