I have a problem trying to bind a property of an object in a mvxBindableListView with MVVMCross and Android.
The structure of the classes is the next:
public class A
{
public string MyPropertyA1 { get; set; }
public int MyPropertyA2 { get; set; }
}
public class B
{
public int MyPropertyB1 { get; set; }
public int MyPropertyB2 { get; set; }
}
public class C
{
public int MyPropertyC1 { get; set; }
public A MyPropertyA { get; set; }
public B MyPropertyB { get; set; }
}
The mvxBindableListView is like that:
<?xml version="1.0" encoding="utf-8"?>
<Mvx.mvxBindableListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/Android.Client"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
local:MvxBind="{'ItemsSource':{'Path':'Results'}}"
local:MvxItemTemplate="@layout/detail_viewmodel" />
Where Results is: public ObservableCollection Results { get; set; }
and the detail_viewmodel is:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/Android.Client"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dip"
android:layout_marginTop="6dip"
android:textAppearance="?android:attr/textAppearanceLarge"
local:MvxBind="{'Text':{'Path':'MyPropertyA.MyPropertyA1'}}" />
When the application runs, it shows me the mvxBindableListView with the number of elements that contains the variable ‘Results’ , but the rows are empty.
Anyone know what is happening? thanks
I tried changing the Tutorial application to use an email with:
And the template to include:
This showed the Guid’s fine.
Looking at your code, because your models do not support INotifyPropertyChanged, then I wonder if you are setting the ViewModel properties before you are binding?
To fix this, I might try:
If your app then shows “TestValue” then you know that the binding is working.
If you then need to get the right values shown, you have two choices: