2015-08-28 57 views
5

我有這樣的佈局: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); 
} 

而在我的視圖模型(屬性更改注入via 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

感謝

+0

與此相關的問題:https://github.com/MvvmCross/MvvmCross/issues/1120 – Martijn00

+0

我有同樣的問題。我的項目使用AppCompat功能。我必須添加Cirrious.MvvmCross.Droid.Support.AppCompat才能在v4 beta 2中工作。不知道這是否適用於您,只需提及它對我的工作。 – GrantVS

+0

不幸的是,這並沒有改變任何東西.. interessting的事情是,它只發生在片段。正常活動的綁定工作正常。 – NPadrutt

回答

0

我建造自己的dll了目前的發展分支。這裏的問題是固定的。所以看來解決方案就是等待beta3 :)