I built a MvxBindableSpinner into my Android-Application:
<TableRow>
<TextView
android:text="Mandant:"
android:width="0px"
android:layout_weight=".22" />
<cirrious.mvvmcross.binding.android.views.MvxBindableSpinner
android:layout_weight=".78"
local:MvxDropDownItemTemplate="@layout/mandantlistitem_dropdown"
local:MvxItemTemplate="@layout/mandantlistitem"
local:MvxBind="{'ItemsSource':{'Path':'Mandanten'},'SelectedItem':{'Path':'SelectedMandant','Mode':'TwoWay'}}"/>
</TableRow>
The MandantClass is simple:
//Class
public class Mandant
{
//Properties
public string MandantBezeichnung { get; set; }
}
The problem I have is, that the SelectedItem isn’t working.. its alway “null”, whatever I choose.. The Property on The ViewModel for the SelectedItem looks like this:
private string selectedMandant;
public string SelectedMandant
{
get { return selectedMandant; }
set { selectedMandant = value; FirePropertyChanged(() => SelectedMandant); }
}
I tried everything, but can’t get it work.. It compiles fine and no errormessages.. but its always null.. Maybe someone can help me?
There are a few things I can suggest about how to debug/fix this.
First, can you set the binding trace level to Diagnostic – somewhere in your code call:
Does this reveal any more information about what is failing?
Second, if you are linking to the source code then try setting a breakpoint and/or adding some additional trace inside
_spinner_ItemSelectedin MvxSpinnerSelectedItemBinding – is this binding event being fired? Is it succeeding all the way through to theFireValueChangedcall?Depending on what that reveals, then try other debug steps like maybe tracing in MvxBindableSpinner.cs.
Third… can you try comparing to an existing sample – I think the Spinner idea came from https://github.com/Zoldeper/Blooor/ originally – so maybe take a look at something like ProductEditView.axml
Does that code work? If so, can you spot the difference.
Warning: the code may have changed since that Blooor sample was written
Finally… and this is just a hunch… can you post a bit more of your ViewModel here? I’m wondering if you have a type mismatch going on… e.g. is your selectedItem a string but should be a Mandant?
If this is a bug in MvvmCross, then ‘sorry’ and please report it as an issue – on https://github.com/slodge/MvvmCross/issues – preferably with a reproducible sample.