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

OrgChart Example

7 Answers 98 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Saher
Top achievements
Rank 1
Saher asked on 16 Jul 2013, 12:34 AM
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

7 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 16 Jul 2013, 07:44 AM
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 >>
0
Saher
Top achievements
Rank 1
answered on 16 Jul 2013, 04:48 PM
Hello Petar,

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

0
Saher
Top achievements
Rank 1
answered on 19 Jul 2013, 04:45 PM
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
0
Petar Mladenov
Telerik team
answered on 22 Jul 2013, 07:16 AM
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 >>
0
Saher
Top achievements
Rank 1
answered on 22 Jul 2013, 05:10 PM
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
0
Saher
Top achievements
Rank 1
answered on 22 Jul 2013, 05:31 PM
Never mind I fixed that using this:

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

0
Petar Mladenov
Telerik team
answered on 23 Jul 2013, 06:09 AM
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 >>
Tags
Diagram
Asked by
Saher
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Saher
Top achievements
Rank 1
Share this question
or