【问题标题】:Add object array to listview in c#在c#中将对象数组添加到listview
【发布时间】:2017-06-21 01:24:08
【问题描述】:

请告诉我如何用 Xamarin 形式的对象数组填充列表视图。

{
    "products": [
        {
            "CODE": "B25-4126"
        },
        {
            "CODE": "F1-2228"
        }
}

谢谢

【问题讨论】:

    标签: c# arrays json xamarin xamarin.forms


    【解决方案1】:

    首先为 JSON 结果创建模型如下:

    public class Product
    {
    public string CODE { get; set; }
    }
    
    public class ProductList
    {
    public List<Product> products { get; set; }
    }
    

    现在将 json 反序列化为 ProductList 模型并将其分配给 listview 的 ItemSource 属性

    【讨论】:

    • 欢迎胖子 :)
    猜你喜欢
    • 1970-01-01
    • 2012-03-11
    • 2011-04-12
    • 1970-01-01
    • 1970-01-01
    • 2022-01-13
    • 2018-09-06
    • 2016-02-06
    • 2021-12-29
    相关资源
    最近更新 更多