Xamarin.form - Masterdetailpage : System.Reflection.TargetInvocationException: 调用目标抛出异常

Xamarin.form - Masterdetailpage : System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation

我已经在使用 xamarin.form 便携

当我使用 MasterDetailPage 时出现错误:"System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation."

下面是我的 xaml 代码

<?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="SlideNavigation.Page1"
              IsPresented="True">
  <MasterDetailPage.Master>
<ContentPage>
  <ListView x:Name="listview" ItemSelected="Listview_itemSelected">
    <ListView.ItemTemplate>
      <DataTemplate>
        <TextCell Text="{Binding Name}" Detail="{Binding Status}"></TextCell>
      </DataTemplate>
    </ListView.ItemTemplate>
  </ListView>
</ContentPage>
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<ContentPage ></ContentPage>
</MasterDetailPage.Detail>
</MasterDetailPage>

下面是我的.cs代码

public partial class Page1 : MasterDetailPage
{
    public Page1()
    {
        InitializeComponent();

        listview.ItemsSource = new List<Contact>
       {
           new Contact { Name = "Kirti",Status = "True"},
           new Contact { Name = "Nilesh",Status = "False"}
       };
    }
    void Listview_itemSelected(object sender, SelectedItemChangedEventArgs e)
    {

        var contact = e.SelectedItem as Contact;
         Detail = new NavigationPage(new  Page2(contact.Name));
        IsPresented = false;
    }
}

请帮我看看我犯了什么错误。

提前致谢

您必须在母版页上设置标题 属性

  <MasterDetailPage.Master>
    <ContentPage Title="Content Page">
      <ContentPage.Content>
        <ListView x:Name="listview" ItemSelected="Listview_itemSelected">
          <ListView.ItemTemplate>
            <DataTemplate>
              <TextCell Text="{Binding Name}" Detail="{Binding Status}"></TextCell>
            </DataTemplate>
          </ListView.ItemTemplate>
        </ListView>
      </ContentPage.Content>
    </ContentPage>
  </MasterDetailPage.Master>