具有Bindable Property的内容页面未在Xamarin Forms上设置值

时间:2016-02-17 14:12:06

标签: c# mvvm xamarin xamarin.forms

我有一个标签页GroupDetailView,我使用Bindable Property IdGroup创建MatchListView的实例,接收GroupDetailViewModel IdGroup的Binding属性,但是Bindable属性没有设置值。怎么了?感谢。

.CS

private int idGroup;
public int IdGroup {
    get { return idGroup; }
    set {
        idGroup = value;
        this.Notify ("IdGroup");
    }
}

public GroupDetailViewModel (int id)
{
    this.IdGroup = id;
    this.GetGroup (id);
}

视图模型

<TabbedPage.Children>
        <ContentPage.ToolbarItems>
        </ContentPage.ToolbarItems>
        <ContentPage.Content>
            ...
        </ContentPage.Content>

    <local:MatchListView IdGroup="{ Binding IdGroup }" />
</TabbedPage.Children>

XAML

public partial class MatchListView : ContentPage
{
    public static readonly BindableProperty IdGroupProperty =
         BindableProperty.Create<MatchListView, int> (c => c.IdGroup, default(int), BindingMode.OneWay, null);

    public int IdGroup
    {
        get { return (int)GetValue(IdGroupProperty); }
        set { SetValue(IdGroupProperty, value); }
    }

    public MatchListView ()
    {
        InitializeComponent ();
        this.BindingContext = new MatchListViewModel ();
    }...

MATCHLISTVIEW

   setVisible(true);
   this.addWindowListener(this);

0 个答案:

没有答案