0
我有這樣的代碼片段使用MvxExpandableListView
MvxExpandableListAdapter SetItemsSource不叫
public class ExpandView : MvxActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.ExpandView);
MvxExpandableListView list = FindViewById<MvxExpandableListView>(Resource.Id.TheExpandView);
list.SetAdapter(new MyCustomAdaptor(this, (IMvxAndroidBindingContext)BindingContext));
}
private class MyCustomAdaptor : MvxExpandableListAdapter
{
private IList _itemsSource;
public MyCustomAdaptor(Context context, IMvxAndroidBindingContext bindingContext)
: base(context, bindingContext)
{
}
protected override void SetItemsSource(IEnumerable value)
{
Mvx.Trace("Setting itemssource");
if (_itemsSource == value)
return;
var existingObservable = _itemsSource as INotifyCollectionChanged;
if (existingObservable != null)
existingObservable.CollectionChanged -= OnItemsSourceCollectionChanged;
_itemsSource = value as IList;
var newObservable = _itemsSource as INotifyCollectionChanged;
if (newObservable != null)
newObservable.CollectionChanged += OnItemsSourceCollectionChanged;
if (value != null)
{
}
else
base.SetItemsSource(null);
}
}
}
當視圖被加載的覆蓋方法SetItemsSource不會被調用,但是當我嘗試從頁面導航離去SetItemsSource被調用一個空值。
我已經設定在XML中的ItemSource地方:MvxBind = 「XYZ的ItemsSource」 –