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
1735
XamDataTree: Getting correct node DataTemplates for subclasses
posted

I'm currently evaluating the XamDataTree to replace a custom WPF multi-selection Tree control. I fail to get the correct DataTemplate to be applied to my node items.

The nodes (ItemsSource) to be displayed in the XamDataTree are of a superclass that further contains a collection of child items of the same superclass, e.g:

 public class ItemBase
    {
        public ItemBase()
        {
            this.Children = new ObservableCollection<ItemBase>();
        }

        public ObservableCollection<ItemBase> Children { get; private set; }
    }

and

 xamDataTree.ItemsSource = new ObservableCollection<ItemBase> ();

The instances (to display)  in the corresponding collections are of subclasses of ItemBase. See the attached project for a simple sample.

In the standard WPF controls, selection of datatemplate for each class is typically done with a DataTemplateSelector, but I can't find any option to use such a feature with the XamDataTree nodes.

I've played around with the 'GlobalNodeLayouts' and 'NodeLayout collections, but fail to succeed; Either the subclasses' datatemplates aren't applied at all, or only one of the templates are selected and applied to all nodes.

All samples I've seen for the XamDataTree only have single class types in e.g. their 'Children' collections. I've never seen any samples using baseclass instances as children objects. Isn't this supported by the XamDataTree framework ?

What is the proper way to set up these subclass DataTemplates ?

Regards,

Leif

 

WpfXamDataTree.zip
Parents Reply Children
No Data