2016-06-28 53 views
0

我试图在xamarin forms中创建一个masterpage的详细信息。简单的逻辑,用户将点击导航页面中的按钮,然后它会发送一些参数到详细页面,并根据该参数我将结合从静止服务列表视图,但我不能发送PARAMS的详细信息页面,我用这个方法,但仍然有错误发送一些参数以详细描述来自master的xamarin形式

private void Button_OnClicked(object sender, EventArgs e) 
     { 

      var item = (Xamarin.Forms.Button)sender; 
       Navigation.PushAsync(new PageDetay(item.CommandParameter.ToString())); 
     } 

我的母版页是这样的

<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms" 
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
      x:Class="paux.Pages.PageMaster" xmlns:local="clr-namespace:paux;assembly=paux"> 
<MasterDetailPage.Master> 
    <ContentPage Title="My page"> 
    <StackLayout Orientation="Vertical"> 
     <ListView x:Name="lstViewMaster" RowHeight="36" > 
      <ListView.ItemTemplate> 
      <DataTemplate> 
       <ViewCell> 
        <ViewCell.View> 
        <Button Text = "{Binding ad}" CommandParameter="{Binding no}" Clicked="Button_OnClicked"/> 
       </ViewCell.View> 
       </ViewCell> 
      </DataTemplate> 
      </ListView.ItemTemplate> 
     </ListView> 
    </StackLayout> 
    </ContentPage> 
</MasterDetailPage.Master> 
    <MasterDetailPage.Detail> 
<local:Pages.PageDetay/> 
    </MasterDetailPage.Detail> 
</MasterDetailPage> 

而我的详细信息页面是这样的

public PageDetay(string id) 
     { 
      InitializeComponent(); 
     } 

任何帮助表示赞赏,谢谢。 错误是完全

namespace paux.Pages { 
using System; 
using Xamarin.Forms; 
using Xamarin.Forms.Xaml; 


public partial class PageMaster : global::Xamarin.Forms.MasterDetailPage { 

    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "0.0.0.0")] 
    private global::Xamarin.Forms.ListView lstViewMaster; 

    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "0.0.0.0")] 
    private void InitializeComponent() { 
     this.LoadFromXaml(typeof(PageMaster)); // this is source of the error 
     lstViewMaster = this.FindByName<global::Xamarin.Forms.ListView>("lstViewMaster"); 
    } 

} 

} 一些xamarin用户的投诉了这个错误,并写了这https://forums.xamarin.com/discussion/25938/missingmethod-exception-default-constructor-not-found 我在IOS禁用链接,但仍然一样,没有什么变化。

+0

你会得到什么错误? – jzeferino

+0

对不起,我忘了写,错误是“System.MissingMethodException:未找到类型paux.Pages.PageDetay的默认构造函数” – slayer35

+0

如果您可以请分享完整的代码。我无法复制这个问题。 – jzeferino

回答

0

我的问题与标题有关,我错过了我的Xaml MasterPage中的标题。在你的lstViewMaster.xaml中你有标题?

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