2016-10-05 48 views
0

XamarinフォームでMasterDetailPageを作成しましたが、上記のエラー。以下は私のMasterDetailPageマスターページのコードビハインドタイプ 'System.Reflection.TargetInvocationException'の例外はmscorlib.ni.dllで発生しましたが、ユーザーコードで処理されませんでした:Xamarinフォーム

<?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:pages="clr-namespace:App2;assembly=App2" 
     x:Class="App2.ParentsMenuPage"> 
<MasterDetailPage.Master> 
<pages:ParentMasterPage x:Name="masterPage" /> 
</MasterDetailPage.Master> 
<MasterDetailPage.Detail> 
<NavigationPage> 
    <x:Arguments> 
    <pages:ParentHomePage /> 
    </x:Arguments> 
    </NavigationPage> 
</MasterDetailPage.Detail> 
</MasterDetailPage> 


The Xaml code for My Master Page is below 


<?xml version="1.0" encoding="utf-8" ?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
     xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
     x:Class="App2.ParentMasterPage" Padding="0,40,0,0"> 
<ContentPage.Content> 
<StackLayout VerticalOptions="FillAndExpand"> 
    <ListView x:Name="listView" VerticalOptions="FillAndExpand" SeparatorVisibility="None"> 
    <ListView.ItemTemplate> 
     <DataTemplate> 
     <ImageCell Text="{Binding Title}" ImageSource="{Binding IconSource}" /> 
     </DataTemplate> 
    </ListView.ItemTemplate> 
    </ListView> 
    </StackLayout> 
</ContentPage.Content> 

ためのXAMLコードは

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

using Xamarin.Forms; 

namespace App2 
{ 
public class ParentMasterItem 
{ 
    public string Title { get; set; } 
    public string IconSource { get; set; } 
    public Type TargetType { get; set; } 
} 

public partial class ParentMasterPage : ContentPage 
{ 
    public ListView ListView { get { return listView; } } 

    public ParentMasterPage() 
    { 
     InitializeComponent(); 

     var masterPageItems = new List<ParentMasterItem>(); 
     masterPageItems.Add(new ParentMasterItem 
     { 
      Title = "Home", 
      IconSource = "images/home-small.png", 
      TargetType = typeof(ParentHomePage) 
     }); 
     masterPageItems.Add(new ParentMasterItem 
     { 
      Title = "My Ward's", 
      IconSource = "images/ward-small.png", 
      TargetType = typeof(ParentWardsPage) 
     }); 
     masterPageItems.Add(new ParentMasterItem 
     { 
      Title = "Chat", 
      IconSource = "images/chat-small.png", 
      TargetType = typeof(ParentChatPage) 
     }); 

     listView.ItemsSource = masterPageItems; 
     } 
     } 
    } 

以下である次に詳細ページ

<?xml version="1.0" encoding="utf-8" ?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
     xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
     x:Class="App2.ParentHomePage"> 

<ContentPage.Content> 
    <StackLayout> 
    <StackLayout.Children> 
    <Frame OutlineColor="Accent"> 
     <Frame.Content> 
     <StackLayout Orientation="Horizontal"> 
      <StackLayout.Children> 
      <Label Text="Home Page" 
        VerticalOptions="Center" /> 
      </StackLayout.Children> 
     </StackLayout> 
     </Frame.Content> 
    </Frame> 

    </StackLayout.Children> 
</StackLayout> 
</ContentPage.Content> 
</ContentPage> 

誰でも助けることができるしてください私は問題がどこにあるか把握する

答えて

0
  1. MyMasterPageにはタイトルが必要です。
  2. MasterDetailsPage.Masterタグの内側で、コンテンツページにタイトルがあることを考慮してください。
関連する問題

 関連する問題