我有一个标签页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);