MvvmCross片段绑定不起作用

时间:2015-08-28 11:01:16

标签: android xamarin mvvmcross

我有这个布局:

<cirrious.mvvmcross.binding.droid.views.MvxListView
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:local="http://schemas.android.com/apk/res-auto"
  android:id="@+id/accountList"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"
  local:MvxItemTemplate="@layout/accountlistitem"
  local:MvxBind="ItemsSource AllAccounts" />

使用以下代码将片段加载到片段中:

public new AccountListViewModel ViewModel
{
    get { return (AccountListViewModel)base.ViewModel; }
    set { base.ViewModel = value; }
}

public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    var ignore = base.OnCreateView(inflater, container, savedInstanceState);
    return this.BindingInflate(Resource.Layout.AccountListLayout, null);
}

在我的ViewModel中(Property Changed通过fody注入):

public ObservableCollection<Account> AllAccounts
{
    get { return accountRepository.Data; }
    set { accountRepository.Data = value; }
}

这不起作用,也不会显示任何数据。但是当我向片段添加以下行时,我的数据显示正确:

    var list = view.FindViewById<MvxListView>(Resource.Id.accountList);
    list.ItemsSource = ViewModel.AllAccounts;

在另一个例子中,这在稳定版本上没有任何问题。绑定似乎也适用于活动,但不适用于片段。对于这个项目,我使用v4.0.0 beta2。我想念一下吗?

链接到GitHub存储库:https://github.com/NPadrutt/MoneyManager

由于

1 个答案:

答案 0 :(得分:0)

我在当前的开发分支中构建了自己的dll。这里的问题是固定的。所以似乎解决方案就是等待beta3:)

相关问题