XAML .NET MAUI中的页眉和页脚

bq8i3lrv  于 2022-12-07  发布在  .NET
关注(0)|答案(1)|浏览(266)

我想做的和这个问题一样,但是对于.NET MAUI:Same header & footer in all WPF windows
所有窗口页眉和页脚都相同

qrjkbowd

qrjkbowd1#

如果你不想点击评论中提供的链接@杰森,这里有一个简短的版本。
页面布局.xaml文件:

<ContentPage ...>

   <Grid RowDefinitions="Auto,*,Auto">

        <!--Row 1 : Header-->
        <Grid>
            <!--header content-->
        </Grid>

        <!--Row 2 : Content-->
        <Grid Grid.Row="1"
              Name="PrimaryPageLayout">
        </Grid>

        <!--Row 3 : Footer-->
        <Grid Grid.Row="2">
            <!--footer content-->
        </Grid>
    
    </Grid>
</ContentPage>

页面布局.xaml.cs文件:

public partial class PageLayout : ContentPage
{
    public IList<IView> PageLayoutContent => PrimaryPageLayout.Children;

    public PageLayout()
    {
        InitializeComponent();
    }
}

子视图.xaml文件:

<PageLayout ... >
    <views:PageLayout.PageLayoutContent>
        <!--Main content-->
    </views:PageLayout.PageLayoutContent>
</PageLayout>

相关问题