Restrict the pan area on diagram

2 posts, 1 answers
  1. Jenny
    Jenny avatar
    3 posts
    Member since:
    May 2016

    Posted 23 Jan Link to this post

    We are using the RadDiagram for Telerik WPF. We have restricted the draggable area using the following link:

    http://docs.telerik.com/devtools/wpf/controls/raddiagram/howto/customize-dragging

    But we also would like to restrict the area that the user is able to pan the diagram. It would be great if it wasn´t possible to pan away from the restricted draggable area. Is this possible, and if yes, how?

    I have tried to use PreviewPan but haven´t figured out if that is the way to go...

  2. Answer
    Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    347 posts

    Posted 25 Jan Link to this post

    Hi Jenny,

    You're on the right path with using PreviewPan, you can cancel a Pan operation by setting the Handled property of the PositionChangedRoutedEventArgs to true.

    Here's a simple example:

    private void Diagram_OnPreviewPan(object sender, PositionChangedRoutedEventArgs e)
    {
        Point myRestrictedPoint = new Point(); 
     
        // If the pan operation is going to go where I don't want it to
        if (e.NewPosition.X > myRestrictedPoint.X || e.NewPosition.Y > myRestrictedPoint.Y)
        {
            // Cancel and return
            e.Handled = true;
            return;
        }
    }


    This should get you what you're looking for. However, if it doesn't please open a Support Ticket here and share the reproducible project code with us so that we can investigate directly. Support Tickets carry a guaranteed response time from the UI for WPF support team (which is within 24 hours for your license).

    Thank you for choosing UI for WPF!

    Regards,
    Lance | Tech Support Engineer, Sr.
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top