WP7 – Pivot Header Style

MANGO UPDATE – This code bombs in 7.1.  Remove the converter to make it work.  I guess that static resource is no longer provided. 

I went back and tested to see if anything changed in 7.0 when you remove the converter and didn’t notice any difference.  So I’m not really sure what it did to begin with.

 

Wanted to share a quick/simple styling for the pivot control header.  This style uses the default text binding and a converter called “FirstCharacter”.  (The naming of this converter makes no sense to me.)   Then sets the color of the header to match the phone accent color.  Its simple but I like it.

<controls:Pivot x:Name="pivot" Grid.Row="1" Title="Acme">            <controls:Pivot.HeaderTemplate>
                <DataTemplate>
                    <TextBlock
                        Text="{Binding Converter={StaticResource FirstCharacter}}"
                        Foreground="{StaticResource PhoneAccentBrush}"/>
                </DataTemplate>
            </controls:Pivot.HeaderTemplate>

Here is a screenshot at the request of Piyush.  Like I said, really simple.

image

8 thoughts on “WP7 – Pivot Header Style”

  1. I’ve tried using your code but I’m getting a warning – “FirstCharacter” could not be resolved. It seems to work ok but I’d like to eliminate (or understand) the warning. Any ideas?
    Dave.

    1. Thats odd … A warning in the Error List? I get a screen squigly under the FirstCharacter reference but I think that is just ReSharper saying “Resource ‘FirstCharacter’ is not found” because it can’t resolve the xaml reference.

Leave a Reply