Blazor Maui 混合应用程序不显示菜单栏

问题描述 投票:0回答:1

当我尝试在 Maui Blazor 混合应用程序中创建菜单栏时,它不会显示,但当我使用与普通 Maui 应用程序中相同的 XAML 时,它会显示。这在混合应用程序中是不可能的吗?我该如何解决这个问题?

混合应用程序:

<?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Stamp"
            xmlns:pages="clr-namespace:Stamp.Components.Pages"
             x:Class="Stamp.MainPage"
             BackgroundColor="{DynamicResource PageBackgroundColor}">

    <ContentPage.MenuBarItems>
        <MenuBarItem Text="File"></MenuBarItem>
    </ContentPage.MenuBarItems>


</ContentPage>

毛伊岛应用程序:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Menuitem_test.MainPage">

    <ContentPage.MenuBarItems>
        <MenuBarItem Text="File"></MenuBarItem>
    </ContentPage.MenuBarItems>

</ContentPage>

Image of the empty page it makes in the Hybrid app

.net xaml menubar maui-blazor
1个回答
0
投票

来自医生,

当将 NET MAUI 桌面应用程序添加到 NavigationPage 或 Shell 应用程序中托管的任何 ContentPage 时,它们将显示一个包含菜单项的菜单栏。

因此您可以轻松更改

App.xaml.cs

MainPage = new NavigationPage(new MainPage());

有关更多信息,您还可以参考在 .NET MAUI 桌面应用程序中显示菜单栏

© www.soinside.com 2019 - 2024. All rights reserved.