2

我正在开发一个 Windows Phone 应用程序。我已将样式添加到Pivot Item.

<phone:PhoneApplicationPage.Resources>
    <Style TargetType="phone:Pivot">
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <Grid/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="phone:Pivot">
                    <Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
  VerticalAlignment="{TemplateBinding VerticalAlignment}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid Background="#D62429" CacheMode="BitmapCache" Grid.RowSpan="2" />
                        <Grid Background="{TemplateBinding Background}" CacheMode="BitmapCache"
    Grid.Row="2" />
                        <ContentPresenter ContentTemplate="{TemplateBinding TitleTemplate}"
                Content="{TemplateBinding Title}" Margin="25,10,0,0" />
                        <Primitives:PivotHeadersControl x:Name="HeadersListElement"
                                      Grid.Row="1" />
                        <ItemsPresenter x:Name="PivotItemPresenter"
              Margin="{TemplateBinding Padding}" Grid.Row="2"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>       
</phone:PhoneApplicationPage.Resources>

它显示这样

在此处输入图像描述

我正在尝试更改以及Pivot ItemWelcomePivot Title和 item 1的字体大小和字体系列。如何更改这些字体的字体大小和字体系列?

4

3 回答 3

6

尝试以这种方式定义 Pivot 项:

 <Grid x:Name="LayoutRoot" Background="Transparent">
    <!--Pivot Control-->
    <controls:Pivot Title="WELCOME" FontSize="30" FontFamily="Arial">
        <!--Pivot item one-->
        <controls:PivotItem >
            <controls:PivotItem.Header>
                <TextBlock Text="item1" FontSize="30" FontFamily="Arial" Margin="0,30,0,0"/>
            </controls:PivotItem.Header>
            <Grid/>
        </controls:PivotItem>

        <!--Pivot item two-->
        <controls:PivotItem >
            <controls:PivotItem.Header>
                <TextBlock Text="item2" FontSize="30" FontFamily="Arial" Margin="0,30,0,0"/>
            </controls:PivotItem.Header>
            <Grid/>
        </controls:PivotItem>
    </controls:Pivot>
</Grid>
于 2013-08-29T04:58:53.447 回答
0

要更改数据透视表头的字体大小或字体系列,请在数据透视表中使用此代码

<phone:Pivot.HeaderTemplate>                
            <DataTemplate>
                <Grid >
                    <TextBlock FontFamily="Times New Roman"  Text="{Binding}" FontSize="20" Height="auto"/>
                </Grid>                 
            </DataTemplate>
</phone:Pivot.HeaderTemplate>
于 2014-11-29T17:49:52.017 回答
0

抱歉,由于某种原因,我看不到您的图片,但我最近回答了非常相似的问题。看看这是否有帮助:

wp8 设置动态数据透视项的标题大小

于 2013-08-28T18:48:32.070 回答