Ich habe ein Problem mit einer Mvvmcross/Xamarin-Anwendung im Droid-Teil. ich ein "MvxSpinner Menü" wich gemacht wird ViewModel.cs auf einer Liste von Paar bindenXamarin.Android/MvvmCross: Navigation mit MvxSpinner
private List<CoupleIntString> _actions = new List<CoupleIntString>() {
new CoupleIntString(0,"Actions"),
new CoupleIntString(1, "Mail"),
new CoupleIntString(2,"Imprimer"),
new CoupleIntString(3, "Totaux"),
new CoupleIntString(4, "Fiche client")
};
public List<CoupleIntString> Actions {
get { return _actions; }
set {
_actions = value;
RaisePropertyChanged(() => Actions);
}
}
droid.axml
<MvxSpinner
android:id="@+id/action_spinner"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="wrap_content"
local:MvxItemTemplate="@layout/item_spinner"
local:MvxDropDownItemTemplate="@layout/item_spinnerdropdown"
local:MvxBind="ItemsSource Actions;SelectedItem ActionSelected" />
Wenn ich ein Element auswählen, ich meine die SelectedAction von Set FirstViewModel und zeige das Viewmodel, das ich laden möchte.
public CoupleIntString ActionSelected {
set {
int xx = value.intPart;
switch (xx) {
case 1: //mail
GoToMailCommand.Execute();
break;
case 2: //impression
GoToImpressionCommand.Execute();
break;
case 3: //totaux
GoToTotauxCommand.Execute();
break;
case 4: //impression
GoToDetailsClientCommand.Execute();
break;
default:
break;
}
}
Aber, wenn ich auf dem FirstViewModel zurückkommen, wird es automatisch neu eingestellt, die SelectedAction und geht zurück zum zweiten Ansichtsmodell. Ich habe versucht, meine SelectedAction in Init, ReloadState, Start, InitFromBundle und ReloadFromBundle auf keine zu setzen, aber nach all diesen Aufrufen gibt es eine andere mit dem Wert, den ich zuvor ausgewählt habe, und ich weiß nicht, wo es herkommt.
Vielen Dank für Ihre Hilfe, aber dies nicht funktioniert . Außerdem versuchen wir, im Droiden-Teil so wenig Code wie möglich zu haben. –