I have deserialized my spinner object, and loaded it in the view model (the property is then bound to SelectedItem). Mvx keeps saying that it could not find the spinner object, that the spinner SelectedItem cannot be null.
I realised that the deserialized spinner object was not part of ItemsSource, since it was deserialized from json. Therefore I searched the corresponding item in ItemsSource and replaced the SelectedItem with the correct object. Now it works.
Is there any cleaner way of doing this? Perhaps I should implement IEquatable in my object. Please advise.
the deserialized spinner object was not part of ItemsSource, since it was deserialized from json. Therefore I searched the corresponding item in ItemsSource and replaced the SelectedItem with the correct object.
I'm not entirely sure what you are asking.
However, hopefully this helps: there is an example of using Equals
to provide object matching in a Spinner in https://github.com/MvvmCross/MvvmCross-Tutorials/blob/master/ApiExamples/ApiExamples.Core/ViewModels/ViewModels.cs#L105