This is a migrated thread and some comments may be shown as answers.

expand children node

1 Answer 128 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
WonYoung
Top achievements
Rank 1
WonYoung asked on 25 Mar 2016, 07:46 AM

If I designed with RadDiagramShape, I can Add/Remove RadDiagramShape in RadDiagram, though.

How can I Visible or Hidden Children nodes in RadDiagram when Node were clicked?

I made some source code for diagram like this:

    public class NodeBase : HierarchicalNodeViewModel
    {

        private long id;
        public long Id
        {
            get { return id; }
            set
            {
                if (id != value)
                {
                    id = value;
                    this.OnPropertyChanged("Id");
                }
            }
        }

         ...(Omit)...
    }

    public class LinkBase : LinkViewModelBase<HierarchicalNodeViewModel>
    {

        private eLinkTypes linkType;
        public eLinkTypes LinkType
        {
            get { return linkType; }
            set
            {
                if (linkType != value)
                {
                    linkType = value;

                    this.OnPropertyChanged("LinkType");
                }
            }
        }
         ...(Omit)...
    }

    public class FlowChartManager : ObservableGraphSourceBase<NodeBase , LinkBase>
    {
          public FlowChartManager()
        {
            PopulateGraphSource();
        }

        public FlowChartManager PopulateGraphSource()
        {
            //Add Nodes
            NodeBase processNode1 = new NodeBase ()
            {
                Position = new Point(10, 10),
                Content = "Process 1",
            }; base.InternalItems.Add(processNode1);

 

            NodeBase processNode2_1 = new NodeBase ()
            {
                Position = new Point(100, 100),
                Content = "Process 2-1",
            }; 

            NodeBase processNode2 = new NodeBase ()
            {
                Position = new Point(100, 100),
                Content = "Process 2",
            };processNode2 .Children.Add(processNode2_1);

             base.InternalItems.Add(processNode2);

 

            NodeBase processNode3 = new NodeBase ()
            {
                Position = new Point(200, 200),
                Content = "Process 3",
            }; base.InternalItems.Add(processNode3);           

 

            //Add Links
            base.InternalLinks.Add(new LinkBase(processNode1, processNode2) { LinkType = eLinkTypes.None, TargetCapType = Telerik.Windows.Diagrams.Core.CapType.Arrow1Filled });

         }

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 29 Mar 2016, 12:57 PM
Hello WonYoung,

You can subscribe for the ShapeClicked event of the RadDiagram which is called when a shape is clicked. Then you can check if the selected node has children and expand /collapse them.
<telerik:RadDiagram ShapeClicked="diagram_ShapeClicked">
We have a OrgChart sample project which demonstrates different RadDigram features and could be in handy for your case. The same example exists for Silverlight (it's almost the same as WPF) in our online resource which you can navigate to by using the following link.

If you have any other questions you can contact us again.

Regards,
Dinko
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
Diagram
Asked by
WonYoung
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or