Q:

wp8 Set header's size of dynamic pivot item

I'm a beginner in windows phone developpement, i've created a pivot application, the pivot's items are filled dynamically, but i can't ajust the fontsize of each titles and i don't know why, this is the xaml interface :
<phone:Pivot  VerticalAlignment="Top"  Name="pivotMainList">
    <phone:PivotItem   Name="titleToday" Margin="12,4,12,0">
        <phone:PivotItem. Header>
           <TextBlock Text="MainPage" FontSize="40"/>
        </phone:PivotItem. Header>
        <Grid Height="357">
           <ListBox ... // some code

and this is the code behind :
for (int i = 0; i <= 20; i++)
{
    var textBlock = new TextBlock { Text = "Pivot " + i, FontSize = 32 };
    PivotItem myNewPivotItem = new PivotItem { Header = textBlock, Name = "piv_" + i };
    Grid myNewGrid = new Grid();
    //... i fill the grid here

    //add pivot to main list
    pivotMainList. Items. Add(myNewPivotItem);
}

And it gives a weird exception: 

HappyConf. DLL!HappyConf. App. Application_UnhandledException(object sender, System. Windows. ApplicationUnhandledExceptionEventArgs e)

A:

One method of changing the font is to create a custom header template resource and then bind the header template property of the pivot to the resource. 
Here's an example:
This code should be in the App.xaml file in the application resource section.  
XAML
<DataTemplate x:Key="SmallPanoramaTitle">
        <ContentPresenter>
            <TextBlock Text="{Binding}" FontSize="50" Margin="0,0,0,0" />
        </ContentPresenter>
    </DataTemplate>

Now for the code behind. 
C#
myNewPivotItem. HeaderTemplate = Resource["SmallPanoramaTitle"] as HeaderTemplate;

