Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
XamTreemap: Using base class in nodebinders
posted

Lets say you have 3 classes. Class A and Class B derive from class C:

Class C { public int c; }
Class B: C { public int b; }

Class A: C { public int a; }

If I create a collection populated with class A & B objects, the node binder doesn't seem capable of treating them like Class C objects:

// somewhere in the code behind... building a collection that is to be assigned to the XamTreemap.ItemsSource property
IList<C> mylist = new List<C>();
mylist.Add(new B());
mylist->Add(new A());


// in xaml:
<ig:NodeBinder TargetTypeName="C" /* other irrelevant property assignments */ >
</ig:NodeBinder>


If i do roughly the above, the control doesn't show anything. If I change the code behind such that I populate mylist with only objects of type Class C, it works just fine:

// changing my code behind to this causes the infragistics control to populate appropriately
IList<C> mylist = new List<C>();
mylist.Add(new C());
mylist->Add(new C());

Is there a way to get the control to treat objects in a list as there base class? Or even an interface might work. The list of objects has other uses than just populating the control. I'd rather not have the code go through the pain staking process of recreating an entire list when that could be thousands of objects that are far more complicated than the ones I've shown here when all I really need is access to the base class properties to properly populate the tree map.