Saturday, 24 August 2013

How to Create a Custom Pivot Title Style

How to Create a Custom Pivot Title Style

I would like to be able to create a custom pivot page title style in my
application, so that I may use it across multiple pages. Essentially I
just want the title of the Pivot to be centered with a certain font size
and type. Originally I was using an Image for my title but I really need a
text title instead. How might I go about doing this? I've already tried
setting this within App.xaml and using it within my MainPage.xaml but so
far I don't have anything working.
App.xaml (original)
<Style x:Key="ApplicationName" TargetType="Image">
<Setter Property="Height" Value="50"/>
<Setter Property="Width" Value="92.85"/>
<Setter Property="Margin" Value="-3,0,0,0"/>
<Setter Property="Source" Value="/Assets/ApplicationTitle.png"/>
</Style>
MainPage.xaml
<phone:Pivot x:Name="mainPagePivotControl" Style="{StaticResource
PivotStyle}">
<phone:Pivot.TitleTemplate>
<DataTemplate>
<Image Style="{StaticResource ApplicationName}"/>
</DataTemplate>
</phone:Pivot.TitleTemplate>
...
</phone:Pivot>

No comments:

Post a Comment