Кажется, у меня возникает странная проблема при привязке MvxListView к моей ViewModel.Я трижды проверил ViewModel и могу подтвердить, что он подключен правильно, так как два других примитивных типа связываются правильно.
Однако, когда я пытаюсь связать с ObservableCollection (или MvxObservableCollection), я получаюнет элементов, отображаемых в MvxListView.Я проследил журналы отладки и не вижу ошибок MvvmCross, а также не вижу проблем с инфляцией в Android.
Я пробовал различные способы поднятия свойства изменились, как вы увидите в моем коде.
Это сводит меня с ума!Любая помощь будет принята с благодарностью.Возможно, мне не хватает чего-то глупого.
ViewModel:
private MvxObservableCollection<ReminderDto> _reminders;
public MainViewModel(IApiService apiService)
{
_apiService = apiService;
}
public override void ViewAppearing()
{
Reminders = new MvxObservableCollection<ReminderDto>()
{
new ReminderDto() { Description = "Test" },
new ReminderDto() { Description = "Test" },
new ReminderDto() { Description = "Test" },
new ReminderDto() { Description = "Test" },
new ReminderDto() { Description = "Test" },
new ReminderDto() { Description = "Test" },
new ReminderDto() { Description = "Test" },
};
RaisePropertyChanged(nameof(Reminders));
}
public MvxObservableCollection<ReminderDto> Reminders
{
get { return _reminders; }
set { SetProperty(ref _reminders, value); }
}
MainView.axml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<MvxListView
android:layout_width="match_parent"
android:layout_height="match_parent"
local:MvxBind="ItemSource Reminders"
local:MvxItemTemplate="@layout/reminder_row" />
Шаблон элемента (Remder_row.axml)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/reminder_danger"
android:weightSum="6">
<TextView
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/textView1" />