XAML 如何在Pivot.RightHeader上水平拉伸内容?

3wabscal  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(117)

混合显示Pivot的模板和下面找到的ContentPresenter,但我在哪里可以找到默认的RightHeaderTemplate?我希望将RelativePanel拉伸到整个右侧标题区域。

<ContentPresenter x:Name="RightHeaderPresenter" ContentTemplate="{TemplateBinding RightHeaderTemplate}" Grid.Column="2" Content="{TemplateBinding RightHeader}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>

例如,TabView.TabStripFooter可以默认提供此功能。
尝试此大小,但无济于事:

<Pivot x:Name="MyPivotTable" ItemsSource="{x:Bind ViewModel.MyItems}" SelectedItem="{x:Bind ViewModel.ActiveDocument, Mode=OneWay}">
    <Pivot.RightHeader>
        <RelativePanel Width="{Binding ElementName=MyPivotTable, Path=RightHeader.ActualWidth}">

控件正向最右对齐:

f1tvaqid

f1tvaqid1#

You can find the default styles, templates in the generic.xaml. AFAIK, you should be able to find the generic.xaml here:
C:\Users???.nuget\packages\microsoft.windowsappsdk\1.1.5\lib\net5.0-windows10.0.17763.0\Microsoft.WinUI\Themes\generic.xaml

UPDATE

You can stretch the RightHeader area by changing the ColumnDefinitions . Since the RightHeaderPresenter is assigned to Grid.Column="2" , this should work:

<PivotPanel
    x:Name="Panel"
    VerticalAlignment="Stretch">
    <Grid x:Name="PivotLayoutElement">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
            <!--
            <ColumnDefinition Width="Auto" />
            -->
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

...

</PivotPanel>

相关问题