OrgChart Example

8 posts, 1 answers
  1. Saher
    Saher avatar
    20 posts
    Member since:
    Jul 2013

    Posted 15 Jul 2013 Link to this post

    Hi,

    I am trying to imitate the OrgChart example you have here OrgChart

    I have succeeded to implement my own data source which passes the ObservableCollection object and represents data in diagram. However, my diagram seems never to have a tree structure even though I create a treeLayout and use the Layout method.

    Here is some more details in the question here on StackOverflow question link

    In particular, which parts of the code are responsible for making the RadDiagtam shapes all line up in a tree-like structure. Now, I get them all in same position (0,0).

    Thanks
  2. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 16 Jul 2013 Link to this post

    Hi Saher,

    We already answered to this question in StackOverflow. I'm posting the answer here too:

    Basically you have two options for such issues:

    1. Add Style for the Shapes that sets default Width and Height of the Shapes. If this does not fill well in your scenario:
    2. Try invoking the Layout in Dispatcher.BeginInvoke

    Dispatcher.BeginInvoke(() => this.treeLayout.Layout(...)

    In addition, I want to mention that we are currently working on improving the Layout mechanism. Our goal is to provide a LayoutAsync() public method that will ensure internally that the shapes are measured and this way the layout will be successful. This will eliminate the current need of workarounds mentioned above.

    Regards,
    Petar Mladenov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Saher
    Saher avatar
    20 posts
    Member since:
    Jul 2013

    Posted 16 Jul 2013 Link to this post

    Hello Petar,

    Thanks a lot! The second option worked perfectly! I appreciate your help.

  5. Saher
    Saher avatar
    20 posts
    Member since:
    Jul 2013

    Posted 19 Jul 2013 Link to this post

    Hello Petar,

    For this option: 
    Dispatcher.BeginInvoke(() => this.treeLayout.Layout(...)

    How can I make this work in WPF?

    Currently I have this working in Silverlight:
     
    Action action = new Action(() => treeLayout.Layout(this.diagram, dataModel.ChildTreeLayoutViewModel.CurrentLayoutSettings));
                this.Dispatcher.BeginInvoke(action);
    I get the tree structure. While when I link a WPF project, I get all the nodes stacked on top of each other. The structure is fine when you move them around, but I want them to show the layout when action is invoked.

    Thanks
  6. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 22 Jul 2013 Link to this post

    Hello Saher,

     In WPF you can use the second parameter of the BeginInvoke method. You can set it to DispatcherPriority.ApplicationIdle or DispatcherPriority.Loaded. The good news is that we have worked on improving this mechanism and in Q2 2013 SP that is right at the door you will be able to simply use LayoutAsync method instead of Dispatchers for both SL and WPF.

    Regards,
    Petar Mladenov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  7. Saher
    Saher avatar
    20 posts
    Member since:
    Jul 2013

    Posted 22 Jul 2013 Link to this post

    Hi

    I should have mentioned that I tried that before but DispatcherPriority was not recognized even though I had :

    using System.Windows.Threading;

    Remember, I am building a Silverlight project (user controls), and I am linking a WPF project to it, so I don't have to duplicate cs code or xaml. Does the DispatcherPriority only appear in WPF project and not in Silverlight?

    Thanks,
    Saher
  8. Saher
    Saher avatar
    20 posts
    Member since:
    Jul 2013

    Posted 22 Jul 2013 Link to this post

    Never mind I fixed that using this:

    #if WPF
                this.Dispatcher.BeginInvoke(action, DispatcherPriority.Background);
    #else
                this.Dispatcher.BeginInvoke(action);
    #endif

  9. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 23 Jul 2013 Link to this post

    Hello Saher,

    Yes, the DispatcherPriority is available for WPF only.
    Once again, please have in mind that with Q2 2013 SP, which will be available till the end of this month, you will be able to use LayoutAsync() method and the property AutoLayout = True. Let us know if you need assistance in upgrading.

    Regards,
    Petar Mladenov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
DevCraft banner