I have a class CustomCollection : IList which maintains a list of CustomObject Types.
我有一个类CustomCollection: IList,它维护CustomObject类型的列表。
This is what I tried, but it's not working (provider.Data is readonly):
这是我尝试过的,但它不起作用(提供者。数据是只读的):
CustomCollection collection1 = somesampledata;
ObjectDataProvider provider = new ObjectDataProvider();
provider.ObjectType = typeof(CustomObject);
provider.Data = collection1;
// could provider.Method = "collection1.GetItems", or something similar work?
Binding binding = new Binding();
binding.Source = provider;
binding.Mode = BindingMode.OneTime;
listBox1.SetBinding(ListBox.ItemsSourceProperty, binding);
1 个解决方案
#1
0
Instead of provider.Data
, try provider.ObjectInstance = collection1
.
而不是提供者。数据,尝试提供者。ObjectInstance =文物。
#1
0
Instead of provider.Data
, try provider.ObjectInstance = collection1
.
而不是提供者。数据,尝试提供者。ObjectInstance =文物。