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

How to make the shape to the viewport's center?

2 Answers 277 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 20 Aug 2016, 11:55 AM
Hi, I want a RadDiagramShape display in the viewport's center, there are many shapes in the RadDiagram. How to do it ?  I found the diagram's viewport.X and viewport.Y, but they are read-only, can not to set. Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 23 Aug 2016, 07:25 AM
Hi Jonathan,

I am not sure what you want to achieve. Do you want to display a shape at the center of the diagram? Or you want to bring the center of the diagram into the view.

To position a shape manually you can use its Position property. To get the currently visible center of the diagram you can use Viewport property and based on it position the shape. For example:
Rect viewport = diagram.Viewport;
double centerX = viewport.X + (viewport.Width / 2);
double centerY = viewport.Y + (viewport.Height / 2);
shape.Position = new Point(centerX, centerY);

To bring the diagram center (0,0) to the view you can use the bring into view feature.
this.diagram.BringIntoView(new Point(0, 0));

Regards,
Martin
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Jonathan
Top achievements
Rank 1
answered on 27 Aug 2016, 09:01 AM
thanks, the BringIntoView is the right method which I want to use.
Tags
Diagram
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Jonathan
Top achievements
Rank 1
Share this question
or