How to set font size on a Windows Phone 7 Pivot or PivotItem control
Asked Answered
A

2

8

I want to set the size of the font in the PivotItem control. Explicitly setting PivotItem FontSize does not seem to do anything, and neither does setting the PivotItem style to "{StaticResource PhoneFontSizeSmall}" The only thing I can find that will change the font size is the FontSize property on the Pivot control, but that only changes the size of the header text of the Pivot itself, but I want to change the size of the PivotItem header text.

Edit: Ok I've learned how to do it using <controls:PivotItem.Header>, but how would I do it using binding? For example:

<controls:Pivot x:Name="pvtKey" 
                        Grid.Row="1" 
                        Height="60"
                        ItemsSource="{Binding Keys}">
    <controls:Pivot.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding}" FontSize="5"/>
        </DataTemplate>
    </controls:Pivot.ItemTemplate> </controls:Pivot>
Anatto answered 5/6, 2011 at 0:16 Comment(0)
D
16
<controls:Pivot Title="whatever" Name="pivot">
    <controls:PivotItem Margin="11,28,13,0" >
        <controls:PivotItem.Header>
            <Grid>
                <TextBlock Name="FirstPivot" FontSize="31" Text="FirstPivot" />
            </Grid>
        </controls:PivotItem.Header>

        <Grid>    <!-- content --> </Grid>

</controls:Pivot>

this should do it

Darleen answered 5/6, 2011 at 7:52 Comment(1)
Thanks. That worked great, but now I've got a situation where I'm binding the Pivot, and now I'm back to the same problem, where I can't control the size when binding.Anatto
A
11

Solved:

<controls:Pivot x:Name="pivot" 
                ItemsSource="{Binding MyItems}"
                SelectedItem="{Binding Path=SelectedItem, Mode=TwoWay}">
    <controls:Pivot.HeaderTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding}" FontSize="20"/>
        </DataTemplate>
    </controls:Pivot.HeaderTemplate>
</controls:Pivot>
Anatto answered 29/6, 2011 at 2:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.