【发布时间】:2021-08-01 12:09:22
【问题描述】:
我想从 API 中获取 XML Entry Control,在 JSON 中可用。
Entry 控件的所有属性都在 JSON 中。我想将它们添加到.xml 页面并在ViewModel(通过数据绑定)中获取它们的值(当用户进入应用程序时)。
更新
根据答案更新代码。
public partial class FormPage : ContentPage, IRootView
{
public List<Form> forms { get; set; }
public class RootObject
{
public bool success { get; set; }
public Datum[] data { get; set; }
}
public class Datum
{
public Form[] form { get; set; }
}
public class Form
{
public string label { get; set; }
public string name { get; set; }
public string type { get; set; }
public int max_length { get; set; }
public bool required { get; set; }
}
public FormPage()
{
InitializeComponent();
var json = @{};
var list = JsonConvert.DeserializeObject<RootObject>(json);
forms = new List<Form>();
forms = list.data.FirstOrDefault().form.ToList();
this.BindingContext = this;
}
}
【问题讨论】:
-
很高兴听到您想做什么,但您明确的问题是什么?到目前为止,您为实现目标做了哪些努力?
标签: c# json .net xamarin xamarin.forms