调整字体大小后枢轴仅显示 header 的一部分

Pivot display only part of the header after font resize

我已经更改了 Pivot 控件的默认样式:

<PivotHeaderPanel x:Name="StaticHeader" Height="200" Visibility="Collapsed"/>
        <PivotHeaderPanel x:Name="Header">
               <PivotHeaderPanel.RenderTransform>
                    <TransformGroup>
                         <CompositeTransform x:Name="HeaderTranslateTransform"/>
                         <CompositeTransform x:Name="HeaderOffsetTranslateTransform"/>
                     </TransformGroup>
         </PivotHeaderPanel.RenderTransform>
</PivotHeaderPanel>

并通过以下方式设置我的 header:

<PivotItem.Header>
                    <TextBlock Height="77"  FontSize="51">Mouse Support</TextBlock>
</PivotItem.Header>

但是标题显示不正确:

如何解决这个问题?

Give TextBlock `height=auto`, and you have also mentioned PivotHeaderPanel height also. That also might be causing problem. Give the sufficient height or give `Height=Auto`


 <PivotItem.Header>
      <TextBlock Height="Auto "  FontSize="51">Mouse Support</TextBlock>
 </PivotItem.Header>

这里的问题是,默认情况下,PivotHeaderItem的高度设置为48,当TextBlock的高度大于48时, 它只会显示其中的一部分。

要找到它,您可以在 Visual Studio 中使用 Live Visual Tree。当你在 Live Visual Tree 中选择 PivotHeaderItem 并查看 Live Properties 时,你会发现它有一个默认样式,其中 Height 设置为 48.

您可以在 PivotHeaderItem styles and templates 找到默认样式。

要解决此问题,您只需在 Page.Resources 中添加以下代码即可将 PivotHeaderItem 的高度设置为自动。并且无需更改Pivot控件的默认样式

<Style TargetType="PivotHeaderItem">
    <Setter Property="Height" Value="Auto" />
</Style>