Skip to main content
A newer version of this page is available.
All docs
V18.2

Display a Tree List using the Built-in IDCTreeNode Domain Component

  • 2 minutes to read

XAF provides the built-in IDCTreeNode Domain Component (DC) that simplifies the use of the TreeList Editors Module in DC-based XAF applications. This Domain Component implements the ITreeNode interface and provides the required Domain Logic for the ITreeNode.Parent and ITreeNode.Children properties. This topic illustrates the use of the IDCTreeNode DC.

Note

If you are not familiar with Domain Components technology, first review the Domain Components Basics topic.

  • Add the ICategory class and replace the automatically generated class declaration with the code below.

    using System.Drawing;
    using DomainComponents.Common;
    // ...
    [DomainComponent]
    [XafDisplayName("Category"), XafDefaultProperty("Name"), ImageName("BO_Category")]
    public interface ICategory : IDCTreeNode {
        [Size(SizeAttribute.Unlimited), Delayed(true), ValueConverter(typeof(ImageValueConverter))]
        Image Image { get; set; }
        [FieldSize(4000)]
        string Description { get; set; }
    }
    
  • Register the newly added DC within the module.

    public sealed partial class DCTreeListExampleModule : ModuleBase {
        // ...
        public override void Setup(XafApplication application) {
            base.Setup(application);
            XafTypesInfo.Instance.RegisterEntity("Category", typeof(ICategory));
        }
    }
    
  • Depending on your target platform, add the TreeListEditorsWindowsFormsModule module to the Windows Forms application or the TreeListEditorsAspNetModule module to your ASP.NET application. To do this, invoke the Application Designer and drag the respective item from the DX.18.2: XAF Modules toolbox section to the Modules pane.

    TreeListEditorsModule_AppDesigner

  • Run the Windows Forms or ASP.NET application to see that the Category List Views are visualized via the TreeListEditor or ASPxTreeListEditor List Editor, respectively.

    TreeListEditorsModule_RunTimeWinWeb

If there is a requirement to show a Category list as a grid in certain Views (e.g in lookups), then invoke the Model Editor for the application project and change the IModelListView.EditorType property value for the required ListView node.