expand children node

2 posts, 0 answers
  1. WonYoung
    WonYoung avatar
    1 posts
    Member since:
    Mar 2016

    Posted 25 Mar Link to this post

    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 });

             }

  2. Dinko
    Admin
    Dinko avatar
    204 posts

    Posted 29 Mar Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top