Issue binding to MVXSpinner after upgrading to Mvv

2019-08-06 07:15发布

问题:

I just updated all of my Mvvmcross libraries to version 4.0.0-beta3 and it looks like it may have broken the binding of the MVXSpinner.

I get the following message in the output:

MvxBind:Warning: 5.40 Failed to create target binding for binding SelectedItem for SelectedColor

Here is the xml:

<MvxSpinner
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:id="@+id/colorSpinner"
               android:spinnerMode="dropdown"                 
               android:layout_below="@id/maintoolbar"
               local:MvxBind="ItemsSource ColorList; SelectedItem SelectedColor" />

Here is the ViewModel:

    public HomeViewModel(IKrizzmaService service, IMvxMessenger messenger)
        :base(service, messenger)
    {
        SelectedColor = "Blue";
    }

    private static string[] _colorList = { "Yellow", "Brown", "White", "Blue", "Orange", "Red", "Green", "Purple" };
    public string[] ColorList
    {
        get { return _colorList; }
    }

    private string _selectedColor;
    public string SelectedColor
    {
        get { return _selectedColor; }
        set
        {
            _selectedColor = value;
            RaisePropertyChanged(() => SelectedColor);                
        }
    }

回答1:

Call MvxAppCompatSetupHelper.FillTargetFactories from your Setup.cs's FillTargetFactories()