C# 在Android中将属性绑定到mvxBindableListView
我在尝试使用MVVMCross和Android绑定mvxBindableListView中对象的属性时遇到问题 这些类的结构如下所示:C# 在Android中将属性绑定到mvxBindableListView,c#,android,mvvmcross,C#,Android,Mvvmcross,我在尝试使用MVVMCross和Android绑定mvxBindableListView中对象的属性时遇到问题 这些类的结构如下所示: public class A { public string MyPropertyA1 { get; set; } public int MyPropertyA2 { get; set; } } public class B { public int MyPropertyB1 { get; set; } public int
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; }
}
mvxBindableListView如下所示:
<?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" />
其中Results为:public observetecollection Results{get;set;}
详细视图模型为:
<?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'}}" />
当应用程序运行时,它向我显示mvxBindableListView,其中包含变量“Results”的元素数,但行为空
有人知道发生了什么吗?谢谢我尝试将教程应用程序更改为使用电子邮件:
public class Thing
{
public string Life { get; set; }
public Thing()
{
Life = Guid.NewGuid().ToString();
}
}
public class SimpleEmail
{
public Thing MyThing { get; set; }
public string From { get; set; }
public string Header { get; set; }
public string Message { get; set; }
public SimpleEmail()
{
MyThing = new Thing();
}
}
模板包括:
<TextView
android:id="@+id/email_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dip"
android:layout_marginTop="6dip"
android:layout_toRightOf="@id/email_from"
local:MvxBind="{'Text':{'Path':'MyThing.Life'}}"
/>
如果你的应用程序显示“TestValue”,那么你就知道绑定正在工作
如果需要显示正确的值,则有两种选择:
我尝试将教程应用程序更改为使用电子邮件:
public class Thing
{
public string Life { get; set; }
public Thing()
{
Life = Guid.NewGuid().ToString();
}
}
public class SimpleEmail
{
public Thing MyThing { get; set; }
public string From { get; set; }
public string Header { get; set; }
public string Message { get; set; }
public SimpleEmail()
{
MyThing = new Thing();
}
}
模板包括:
<TextView
android:id="@+id/email_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dip"
android:layout_marginTop="6dip"
android:layout_toRightOf="@id/email_from"
local:MvxBind="{'Text':{'Path':'MyThing.Life'}}"
/>
如果你的应用程序显示“TestValue”,那么你就知道绑定正在工作
如果需要显示正确的值,则有两种选择: