У меня есть очень простой фрагмент кода:
<?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>
ViewModel содержит следующий код:
private ObservableCollection<string> _items = new ObservableCollection<string>()
{
"One", "Two", "Three"
};
public ObservableCollection<string> Items
{
get
{
return _items;
}
set { _items = value; RaisePropertyChanged(() => Items); }
}
Однако при запуске приложения ничего не отображается.Обычный счетчик показывает свои элементы, так как у меня есть код в самом классе представления, скопированный с сайта Xamarin, например:
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;
Чего мне не хватает?