The spinner binding isn't perfect in MvvmCross - in particular, the SelectedItem
change must be sent after the ItemsSource
change.
To work around this, you could signal a fake SelectedItem
change after the ItemsSource
- e.g. something like:
RaisePropertyChanged(() => item_source_two);
RaisePropertyChanged(() => selected_item_two);
If you wanted to fix this more fully, you could also consider overriding MvxSpinner - sadly you can't easily inherit because we missed virtual, but you do something like:
public class MySpinner : MvxSpinner
{
public MySpinner(Context context, IAttributeSet attrs)
: base(context, attrs)
{
}
[MvxSetToNullAfterBinding]
public new IEnumerable ItemsSource
{
get { return base.ItemsSource; }
set
{
// TODO - work out what the current selection and store it in a local variable
base.ItemsSource = value;
// TODO - reset the current selection here from the local variable
}
}
}
inheriting from https://github.com/MvvmCross/MvvmCross/blob/v3.1/Cirrious/Cirrious.MvvmCross.Binding.Droid/Views/MvxSpinner.cs