I’m trying to add a PivotItem to a Pivot dynamically at load time. I need some screen estate and the standard pivot item header font was too big for me. Some forum searching has lead to this solution:
<controls:PivotItem>
<controls:PivotItem.Header>
<TextBlock FontSize="{StaticResource PhoneFontSizeLarge} Text="MyHeaderText"/>
</controls:PivotItem.Header>
</controls:PivotItem>
This solution works okay if I defined it within the pivotitem XAML itself, but how I can do this in C# code?
You just need to create a
Pivotobject and somePivotItemsobjects and then add thosePivotItemsto thePivot. At last add thisPivotto yourLayoutRootwhich is likely aGrid.Something like this,