我有一个自定义类:
public class myField {
public string MyName;
public string MyDataType;
public Field details;
}
自定义课程" Field"是从导入的Salesforce.com合作伙伴WSDL定义的。它看起来像这样:
public class Field {
public string name;
public string label;
public string type;
public int length;
public bool custom;
... // there are probably 50+ defined properties here
}
我创建了一个myField对象列表,用于保存这些字段的列表:
public List<myField> MasterList = new List<myField>();
这个列表是通过一些API调用填充的,我已经验证了数据是否存在且不为空。
我的目标是显示字段&#34; MyName&#34;,&#34; MyDataType&#34;以及&#34;详细信息&#34;下的所有子属性。字段,在ListView中。
public GridView myGridView = new GridView();
GridViewColumn theColumn;
theColumn = new GridViewColumn();
theColumn.Header = "MyName";
theColumn.DisplayMemberBinding = new Binding("MyName");
myGridView.Columns.Add(theColumn);
theColumn = new GridViewColumn();
theColumn.Header = "length";
theColumn.DisplayMemberBinding = new Binding("details.length");
myGridView.Columns.Add(theColumn);
myListView.View = myGridView;
myListView.ItemsSource = MasterList;
我遇到的问题是,我尝试显示的任何主要属性都可以正常工作(MyName,MyDataType),但任何子属性(我通过&#34;详细信息&#34;字段)根本不显示(名称,标签,类型,长度,自定义等)。
binding = "MyName" // displays correctly
binding = "MyDataType" // displays correctly
binding = "details.name" // does not display correctly
binding = "details.label" // does not display correctly
etc
有谁知道如何解决这个问题?
答案 0 :(得分:0)
我复制了您的代码,甚至MyName
和MyDataType
都无法显示,除非我将其更改为
public class myField {
public string MyName {get; set;}
public string MyDataType {get; set;}
public Field details {get; set;}
}
public class Field {
public string name {get; set;}
public string label {get; set;}
public string type {get; set;}
public int length {get; set;}
public bool custom {get; set;}
}
然后一切正常