1

我想在 MainPage 中这样导航:

private async void btnNav_Clicked(object sender, EventArgs e)
{
    await Navigation.PushAsync(new Pages.Nav1Page());
}

这不起作用。然后我知道我需要使用NavigationPageto wrap MainPage,如下所示:

public MainWindow()
{
    Page = new NavigationPage(new MainPage());
}

NavigationPage没有实现IPage接口。

4

2 回答 2

2

在 Weather21 演示应用中找到 - 像这样更改您的 app.xaml.cs

public partial class App : Application
{
    public App()
    {
        InitializeComponent();
    }

    protected override Window CreateWindow(IActivationState activationState) =>
        new Window(new NavigationPage(new MainPage())) { Title = "MyApp" };
}
于 2021-09-16T10:44:29.760 回答
1

尝试这个:

public partial class App : Application
{
    public App()
    {
        InitializeComponent();

        MainPage = new NavigationPage();
        MainPage.Navigation.PushAsync(new MainPage());
    }
}
于 2022-02-12T10:57:05.853 回答