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

3 posts, 1 answers
  1. Jonathan
    Jonathan avatar
    26 posts
    Member since:
    Jan 2016

    Posted 20 Aug Link to this post

    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. Answer
    Martin avatar
    1051 posts

    Posted 23 Aug Link to this post

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

    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. DevCraft banner
  4. Jonathan
    Jonathan avatar
    26 posts
    Member since:
    Jan 2016

    Posted 27 Aug in reply to Martin Link to this post

    thanks, the BringIntoView is the right method which I want to use.
Back to Top