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
873
Different NodeLayouts for different classes implementing the same interface.
posted

Hello,

I have the following situation: I have an interface IBasicTreeItem which is used as the basic interface for all tree nodes. I also implemented two classes that implement this interface. The classes are NodeTreeItem (for non-leaf nodes) and LeafNodeTreeItem (for leaf nodes).

public interface IBasicTreeItem
    {

       ...

        IEnumerable<IBasicTreeItem> Children { get; }
    }

    public class NodeTreeItem : IBasicTreeItem
    {
        ...
    }

    public class LeafNodeTreeItem : BasicTreeItem
    {
       ...
    }

The ItemsSource of the XamDataTree binds to a colelction of IBasicTreeItem objects.

In XAML I want to have different layouts for the different types, like for example

<ig:NodeLayout Key="NodeLayout" TargetTypeName="BasicTreeItem"> 

...

 </ig:NodeLayout>

 

<ig:NodeLayout Key="LeafNode" TargetTypeName="LeafNodeTreeItem"> 

...

 </ig:NodeLayout>

Using the standard TreeView and DataTemplates for the above two classes, it is very easy to achieve this. But how can that be done with the XamDataTree?

 

Thanks a lot in advance,

Raja

Parents
No Data
Reply
  • 21382
    posted

    This can be achieved by handling the NodeLayoutAssigned event off the tree. During this event you can set the NodeLayout to be used with the particular NodesManager

     

     

     

     

     

     

     

     

    private void tree_NodeLayoutAssigned(object sender, Infragistics.Controls.Menus.NodeLayoutAssignedEventArgs

    e)

    {

     

     

     

    if

    (e.Level == 0)

    {

    e.NodeLayout = tree.GlobalNodeLayouts[

     

     

    "teamLayouts"

    ];

    }

     

     

     

    else

    {

    e.NodeLayout = tree.GlobalNodeLayouts[

     

     

    "playerLayouts"

    ];

Children
No Data