我有这样的布局:
<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" />
使用以下代码将布局加载到 fragment 中:
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 注入(inject)的):
public ObservableCollection<Account> AllAccounts
{
get { return accountRepository.Data; }
set { accountRepository.Data = value; }
}
这将不起作用,也不会显示任何数据。但是当我将以下行添加到 fragment 时,我的数据会正确显示:
var list = view.FindViewById<MvxListView>(Resource.Id.accountList);
list.ItemsSource = ViewModel.AllAccounts;
在另一个例子中,这在稳定版本上没有任何问题。此外,绑定(bind)似乎在 Activity 中有效,但在 fragment 中无效。对于这个项目,我使用 v4.0.0 beta2。我错过了什么吗?
GitHub 存储库链接:https://github.com/NPadrutt/MoneyManager
谢谢
最佳答案
我从当前的开发分支构建了自己的 dll。此处问题已解决。所以看来解决方案就是等待 beta3 :)
关于android - MvvmCross fragment 绑定(bind)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32269526/