PanTool and Item Selection

2 posts, 0 answers
  1. GR
    GR avatar
    2 posts
    Member since:
    Dec 2012

    Posted 07 May 2013 Link to this post

    Is there a way to prevent diagram items from being selected and moved while the active tool is the pan tool?  When pan is enabled, I would like item manipulation to be disabled.  As I see it, pan only works on empty areas of the diagram.
  2. Pavel R. Pavlov
    Pavel R. Pavlov avatar
    1236 posts

    Posted 10 May 2013 Link to this post


    I already answered to this question in your support ticket. However, I will also post the same answer in this forum thread so that others from the community will be able to find it.

    This behavior is not supported out-of-the-box. However, in order to achieve your requirement, you can use the IHitTestService. This service is called on each MouseDown event. Hence, if the diagram doesn't know that there is an item under the mouse (when you want to pan) the control will start pan operation otherwise (if the control knows that there is a shape under the mouse) it will start drag operation. You can do this by subscribing to the PreviewMouseLeftButtonDown event of the RadDiagram control and setting the ItemUnderMouse property of the service to return null.

    Furthermore, in order to allow the dragging of items when the CTRL key is not pressed you will have to set back the default service. This can be done in the MouseUp event handler of the RadDiagram control.

    For your convenience we implemented this approach in the attached project. Please take a look at it and let us know if it works in your certain scenario.

    On the other hand, the same functionality can be achieved by setting the IsEnabled property of any item to False. By doing so, you will be able to start panning on top of the that item and you will disable it (and its manipulations).

    Pavel R. Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top