Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Silverlight Hierarchy Tree Control

, 19 Oct 2010
A Hierarchy Tree with the ability to display any control as a node
HierarchyControl_scr.zip
HierarchyControl
Croll.Silverlight.Controls
Bin
Debug
Release
Croll.Silverlight.Controls.csproj.user
Properties
HierarchyControl
HierarchyControl.suo
HierarchyControl.Web
bin
ClientBin
HierarchyControl.xap
HierarchyControl.Web.csproj.user
Properties
Bin
Debug
HierarchyControl.csproj.user
Properties
View
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace Croll.Silverlight.Controls
{
    /// <summary>
    /// Represents a node in the HierarchyTree NodeControl
    /// </summary>
    /// <remarks>This class is a prime candidate to inherit the PresentationFrameworkCollection<T> class 
    /// to allow developers to interact with the HierarchyTree Nodes in the Properties window in the same way nodes 
    /// can be added to a TreeView.  Unfortunately due to few abstract internal methods, this is not possible
    /// </remarks>
    public class HierarchyNode
    {

        private FrameworkElement control;
        private List<HierarchyNode> children = new List<HierarchyNode>();

        /// <summary>
        /// Creates an instance of the HierarchyNode class and sets the controls width and height,
        /// </summary>
        /// <remarks>
        /// Due to the asyncronous nature of Silverlight the actual width and height of the NodeControl
        /// is not known until the HierarchyTree is displayed
        /// </remarks>
        /// <param name="NodeControl">Control to display in HierarchyTree</param>
        /// <param name="width">Width of NodeControl to display</param>
        /// <param name="height">Height of NodeControl to display</param>
        public HierarchyNode(FrameworkElement control, double width, double height)
        {
            this.control = control;
            control.Width = width;
            control.Height = height;
        }

        /// <summary>
        /// Control used to visually represent the node
        /// </summary>
        public FrameworkElement Control
        {
            get { return this.control; }
            set { control = value; }
        }

        public List<HierarchyNode> Children
        {
            get { return this.children; }
            set { children = value; }
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

RobCroll

Australia Australia
Enjoying life developing mobile device software for Contractors Apps and Ezi App.
 
I also teach C#, Java and Project Management a couple of evenings a week.
 
Prior to moving to DCB, I'd been a Windows software developer for nearly 15 years

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 19 Oct 2010
Article Copyright 2010 by RobCroll
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid