Xamarin - 在将MasterDetailPage添加到容器之前必须设置Master和Detail

Far*_*rax 9 xamarin xamarin.forms

我正在尝试将一个简单的Master Detail页面添加到现有的Xamarin应用程序中.这是MasterDetailPage声明

<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
                  xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                  xmlns:pages="clr-namespace:MyCareManager.XamForms.Pages;assembly=MyCareManager.XamForms"
                  x:Class="MyCareManager.XamForms.Pages.SettingsPage">
  <MasterDetailPage.Master>
    <ContentPage Title="This is the test master page"></ContentPage>
  </MasterDetailPage.Master>
  <MasterDetailPage.Detail>
    <NavigationPage>
      <x:Arguments>
        <ContentPage Title="This is a view"></ContentPage>
      </x:Arguments>
    </NavigationPage>
  </MasterDetailPage.Detail>
</MasterDetailPage>
Run Code Online (Sandbox Code Playgroud)

但是,当我运行应用程序时,导航到页面时出现以下错误:

在将MasterDetailPage添加到容器之前,必须先设置Master和Detail

我假设它与autofac一样,在应用程序中用作IOC容器,但还没有能够指责它.还有其他人经历过这个吗?

fan*_*dro 4

如果有人需要的话,这是我的运行代码:

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="CrossApp1.MenuPage">
        <MasterDetailPage.Master>
          <ContentPage Title="Menu">
            <StackLayout Orientation="Vertical">
              <Button Text="Sports"/>
              <Button Text="Economy"/>
              <Button Text="Education"/>
              <Button Text="Science"/>
            </StackLayout>
          </ContentPage>
        </MasterDetailPage.Master>

        <MasterDetailPage.Detail>

          <NavigationPage>
            <x:Arguments>
              <ContentPage Title="This is a view"></ContentPage>
            </x:Arguments>
          </NavigationPage>
        </MasterDetailPage.Detail>
</MasterDetailPage>
Run Code Online (Sandbox Code Playgroud)