views:

60

answers:

1

I have a class CustomCollection : IList which maintains a list of CustomObject Types.

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);
A: 

Instead of provider.Data, try provider.ObjectInstance = collection1.

Charlie
Thanks! provider.ObjectInstance = collection1.GetItems() works! (But you have to remove the line provider.ObjectType = or you get an exception - you can only assign one of those properties )
evan