I have a very simple snippet as follows:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/lib/com.myco.app"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="20px">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="24dp"
android:layout_marginTop="10dip"
android:text="@string/planATripLabel"
android:textColor="#FF9900" />
<Spinner
android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/planet_prompt" />
<!--local:MvxBind="ItemsSource Items; " />-->
<MvxSpinner
android:id="@+id/spinner1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/planet_prompt"
local:MvxBind="ItemsSource Items" />
</LinearLayout>
The ViewModel contains the following code:
private ObservableCollection<string> _items = new ObservableCollection<string>()
{
"One", "Two", "Three"
};
public ObservableCollection<string> Items
{
get
{
return _items;
}
set { _items = value; RaisePropertyChanged(() => Items); }
}
However, when I run the application nothing is displayed. The regular spinner does show its items as I have code in the view class itself copied from Xamarin's site like so:
Spinner spinner = FindViewById<Spinner>(Resource.Id.spinner);
spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
var adapter = ArrayAdapter.CreateFromResource(
this, Resource.Array.planets_array, Android.Resource.Layout.SimpleSpinnerItem);
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
spinner.Adapter = adapter;
What am I missing?
I think your
localnamespace is not taking into accountMvxBind.I'd replace
xmlns:local="http://schemas.android.com/apk/lib/com.myco.app"with (I always use it like this, with res-auto)
xmlns:local="http://schemas.android.com/apk/res-auto"And if that's not the problem I'd provide a custom
MvxItemTemplateand a customMvxDropDownItemTemplateto theMvxSpinnerto see if the defaults are not working. And also check theOutputwindow to see if any errors are being displayed.If you need any help with that just tell me.
HIH