0
我有一个对象模型类(desarlise json to object model),我想使用绑定将对象模型附加到使用xamarin表单的UI。将对象模型绑定到xamarin表单中的UI
P.S本身并非XAML,而是通过代码。
有在互联网上搜索,但它变得越来越混乱
任何帮助都将急切地有用
感谢
我有一个对象模型类(desarlise json to object model),我想使用绑定将对象模型附加到使用xamarin表单的UI。将对象模型绑定到xamarin表单中的UI
P.S本身并非XAML,而是通过代码。
有在互联网上搜索,但它变得越来越混乱
任何帮助都将急切地有用
感谢
你的问题是有点不清楚,但这里的数据Xamarin.Forms
结合的例子在代码中。
//INPC implementation removed in this sample
public class PersonViewModel
{
public string FirstName {get;set;}
public string LastName {get;set;}
}
var person = new PersonViewModel {
FirstName = "John",
LastName = "Doe",
};
var first = new Label();
first.SetBinding (Label.TextProperty, "FirstName");
var label = new Label();
label.SetBinding (Label.TextProperty, "LastName");
var personView = new StackLayout {
Orientation = StackOrientation.Horizontal,
Children = {
first,
last
}
};
personView.BindingContext = person;