且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Xamarin.Forms FlyoutPage 不适用于 Prism

更新时间:2023-02-05 20:17:53

更新:除了我在问题中修复的旧答案之外,根据 这个.计划用于 8.1.因此,您可以等待 8.1 或将其替换为 MasterDetailPage.我用 MasterDetailPage 尝试了你的例子,它对我来说很好:

Update: In addition to my old answer, which you have fixed in the question, it seems that the FlyoutPage is not supported by Prism 8 according to this. It is planned for 8.1. So, you can either wait 8.1 or replace it with MasterDetailPage. I tried your example with MasterDetailPage and it worked fine for me:

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
                  xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                  xmlns:prism="http://prismlibrary.com"
                  prism:ViewModelLocator.AutowireViewModel="True"
                  x:Class="PrismNavigation.Views.Page3">

    <MasterDetailPage.Master>
        <ContentPage Title="Menu">
            <StackLayout Padding="20">
                <Button Text="Page2" HeightRequest="50" WidthRequest="100" Command="{Binding NavigateCommand}" CommandParameter="Page2"></Button>
            </StackLayout>
        </ContentPage>
    </MasterDetailPage.Master>
    
    <MasterDetailPage.Detail>
      <NavigationPage>
        <x:Arguments>
            <ContentPage Title="This is Page1"></ContentPage>
        </x:Arguments>
      </NavigationPage>
    </MasterDetailPage.Detail>
    
</MasterDetailPage>

旧答案:似乎您没有向 NavigateCommand 传递任何参数.试试这个

Old answer: Seems like you didn't pass any parameter to your NavigateCommand. Try this

<StackLayout>
    <Button Text="Page2" HeightRequest="50" WidthRequest="100" Command="{Binding NavigateCommand}" CommandParameter="Page2"></Button>
</StackLayout>