xaml – 如何更改模板中数据透视表项目标题的大小

前端之家收集整理的这篇文章主要介绍了xaml – 如何更改模板中数据透视表项目标题的大小前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我希望能够修改默认的数据透视表模板来更改数据透视表项标题的大小.我如何使用以下样式执行此操作
<Style x:Key="PivotStyle" 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 CacheMode="BitmapCache" Grid.RowSpan="2" >
                            <Grid.Background>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <GradientStop Color="Transparent" Offset="0.0" />
                                    <GradientStop Color="Transparent" Offset="1.0" />
                                </LinearGradientBrush>
                            </Grid.Background>
                        </Grid>
                        <Grid Background="{TemplateBinding Background}" CacheMode="BitmapCache" Grid.Row="2" />
                        <ContentPresenter ContentTemplate="{TemplateBinding TitleTemplate}" Content="{TemplateBinding Title}" Margin="24,17,-7" />
                        <Primitives:PivotHeadersControl x:Name="HeadersListElement" Foreground="{StaticResource PhoneForegroundBrush}" FontSize="28" Grid.Row="1"/>
                        <ItemsPresenter x:Name="PivotItemPresenter" Margin="{TemplateBinding Padding}" Grid.Row="2"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

我试图让这个模仿以下

您可以通过更改HeaderTemplate来更改您的Pivot Header的字体大小,族等等:
<phone:Pivot Title="PivotTest" Style="{StaticResource PivotStyle}">
     <phone:Pivot.HeaderTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding}" FontSize="10"/>
        </DataTemplate>
     </phone:Pivot.HeaderTemplate>
     <phone:PivotItem Header="One">
          // item 1  
     </phone:PivotItem>
     <phone:PivotItem Header="Two">
          // item 2
     </phone:PivotItem>
</phone:Pivot>

编辑 – 在一种风格:

<phone:PhoneApplicationPage.Resources>
    <DataTemplate x:Key="myHeader">
        <TextBlock Text="{Binding}" FontSize="10"/>
    </DataTemplate>

    <Style x:Key="PivotStyle" TargetType="phone:Pivot">
        <Setter Property="HeaderTemplate" Value="{StaticResource myHeader}"/>
        <Setter Property="Margin" Value="0"/>
        ....
原文链接:https://www.f2er.com/windows/363344.html

猜你在找的Windows相关文章