I'm aiming to mimic similar effect as seen here: http://www.visuallylocated.com/post/2012/05/23/Changing-the-background-color-of-your-pivot-headers.aspx . There are resources online describing how to do it, but all of them apply to Windows Phone 8. 8.1 update brought severe API changes, making the code useless.
So, how can I style pivot header? I found namespace Windows.UI.Xaml.Controls.Primitives, which includes class PivotHeaderPanel, which might be helpful in this situation, but I can't find a way to access this class from XAML. Or maybe there is another way?
If you just want to change the background color of all the headers, this is how you can do it in Window Phone 8.1.
First, use Expression Blend to generate the default style of the
Pivot
control.Find this line below, the only change I have made to the default style is adding
Background="{TemplateBinding BorderBrush}"
to thePivotHeaderPanel
which is the panel that hosts all the headers.The reason that I use
TemplateBinding
here is because doing this gives me the flexibility to change the headers background by specifying theBorderBush
of thePivot
. As theBorderBrush
is not used anywhere in the control, there won't be any side effect if we change it.So, all you need to do in your
Pivot
is this.This is how they look now.
Hope this helps!
So 8.1 killed how I used to do HeaderTemplates.
My solution now is to put a customized TextBlock or Control in the Header element of the PivotItem.