本文介绍了XamarinForms DataGridView(DevExpress)在某些字段上不显示值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

CustomersList和客户列表.

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

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

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

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

 公共类客户:INotifyPropertyChanged {公共字符串Oid {get;放;}公共字符串名称{get;放;}公共字符串Title {get;放;}公共字符串代码{放;}公共字符串AFM {get;放;}公共字符串电子邮件{get;放;}公共字符串DOY {get;放;}公共字符串职业{get;放;}公共长CategoryFPA {get;放;}私人列表<客户>_CustomersList {get;放;}公开列表<客户>客户清单{得到{返回_CustomersList;}放{如果(值!= _CustomersList){_CustomersList =值;NotifyPropertyChanged();}}}公共事件PropertyChangedEventHandler PropertyChanged;受保护的void NotifyPropertyChanged([CallerMemberName]字符串propertyName ="){PropertyChanged?.Invoke(this,new PropertyChangedEventArgs(propertyName));}} 

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

  var content =等待响应.Content.ReadAsStringAsync();var customerJson = Regex.Unescape(content.Substring(1,content.Length-2));var customer = JsonConvert.DeserializeObject< List< Customers>>(customersJson);客户列表=新列表<客户>(客户); 
解决方案

Copy your Json data and the follow the stpes in your Visual Studio.

Visual Studio Menu> Edit> Paste Special> Paste As Json Classes. It would generate the correct Customers class you want.

这篇关于XamarinForms DataGridView(DevExpress)在某些字段上不显示值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 02:29