加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

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

发布时间:2020-12-14 01:48:38 所属栏目:Windows 来源:网络整理
导读:我希望能够修改默认的数据透视表模板来更改数据透视表项标题的大小.我如何使用以下样式执行此操作 Style x:Key="PivotStyle" TargetType="phone:Pivot" Setter Property="Margin" Value="0"/ Setter Property="Padding" Value="0"/ Setter Property="Foregro
我希望能够修改默认的数据透视表模板来更改数据透视表项标题的大小.我如何使用以下样式执行此操作
<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"/>
        ....

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读