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 propertyIList<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 appropriatelyIList<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.
Hi Ryan,
I am attaching a sample where I have tried to reproduce your scenario:
1. I am having the two classes (A and B), both derive from C;
2. I am binding the XamTreemap instance to a collection that is similar to the one form the code snippet above;
3, I am instantiating the XamTreemap in XAML and adding a NodeBinder with the relevant properties;
If the attached solution does not match your scenario, please let me know so I can provide further assistance.
Thanks,
Stefana
Thanks Stefana for putting together the sample project. It does look like it matches my scenario. When I run the code "as-is", I get the message:
"There are not any valid treemap nodes. Please check the items source and data binders.".
If I change your code such that the list you populated gets populated only with ClassC objects, then it works as expected. So, yes, the project you've attached seems to demonstrate the problem I am seeing. At least locally on my machine.
Again, the only code change I made was this:
void MainPage_Loaded(object sender, RoutedEventArgs e) { List<ClassC> mylist = new List<ClassC>(); mylist.Add(new ClassC() { c = 11 }); mylist.Add(new ClassC() { c = 12 }); mylist.Add(new ClassC() { c = 13 }); mylist.Add(new ClassC() { c = 21 }); mylist.Add(new ClassC() { c = 22 }); mylist.Add(new ClassC() { c = 23 }); this.myTreemap.ItemsSource = mylist; }