XamarinForms DataGridViewDevExpress在某些字段上不显示值

问题描述

所以我正在使用Web服务,并且我具有以下价值:

CustomersList和客户列表。

当我像这样将数据绑定到网格时:

<ContentPage.BindingContext>
    <vm:ApiVewModel/>
</ContentPage.BindingContext>
<dxg:DataGridView x:Name="grid" ItemsSource="{Binding CustomersList}">
</dxg:DataGridView>

我可以看到表格,但只能看到某些字段,例如OID和CategoryFPA。 显示了其他列,但它们为空。在Json(响应)中,它们具有值。

有什么问题的主意吗?我的客户类是:

  public class Customers : INotifyPropertyChanged {
    public String Oid { get; set; }
    
    public string Name { get; set; }

    public string Title { get; set; }

    public string Code { get; set; }

    public string AFM { get; set; }

    public String Email { get; set; }

    public string DOY { get; set; }

    public string Occupation { get; set; }
   
    public long CategoryFPA { get; set; }

    private List<Customers> _CustomersList { get; set; }
    public List<Customers> CustomersList
    {

        get
        {
            return _CustomersList;
        }

        set
        {
            if (value != _CustomersList)
            {
                _CustomersList = value;
                NotifyPropertyChanged();
            }
        }

    }
    public event PropertyChangedEventHandler PropertyChanged;
    protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
    {
        PropertyChanged?.Invoke(this,new PropertyChangedEventArgs(propertyName));
    }

}

我用来获取数据并将其放入客户列表的代码:

                var content = await response.Content.ReadAsStringAsync();
            var customersJson = Regex.Unescape(content.Substring(1,content.Length - 2));
            var customers = JsonConvert.DeserializeObject<List<Customers>>(customersJson);
            CustomersList = new List<Customers>(customers);

编辑:我想json文件和绑定很好!问题在于包装JSON文件的Customers类。但是我是从jsontoc#传递过来的,这是它为包装器生成的类。那么包装字段的合适方法是什么?

解决方法

那么包装字段的合适方法是什么?

复制您的Json数据,并按照Visual Studio中的步骤进行操作。

Visual Studio菜单>编辑>选择性粘贴>作为Json类粘贴。它将生成您想要的正确的Customer类。

enter image description here

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...