Pan while mouse over container shape

2 posts, 0 answers
  1. Alex
    Alex avatar
    16 posts
    Member since:
    Oct 2011

    Posted 29 Sep 2014 Link to this post

    I've already changed the diagram's activetool to the pan tool, but this does not seem to take affect when the mouse is over a container shape, some of my container shapes are very large, and I don't really need the capability to select them, so is it possible to make the mouse pan while over a container shape?
  2. Martin
    Martin avatar
    1042 posts

    Posted 01 Oct 2014 Link to this post

    Hello Alex,

    Indeed, when the mouse is over a container or a shape, the selection behavior have bigger precedence then the ActiveTool. However, you can achieve your requirement using a custom PointerTool. 

    Here are few snippets that demonstrates such approach:
    var toolService = this.diagram.ServiceLocator.GetService<IToolService>() as ToolService;
    toolService.ToolList[0] = new MyPointerTool();

    public class MyPointerTool : PointerTool
        public override bool MouseDown(PointerArgs e)
            var result = base.MouseDown(e);
            if (this.HitItem != null && this.DontLikeHitItem())
                this.HitItem = null;
            return result;
        private bool DontLikeHitItem()
            return !MyProperties.GetCanSelect(this.HitItem as FrameworkElement);
    public static class MyProperties
        public static readonly DependencyProperty CanSelectProperty =
            DependencyProperty.RegisterAttached("CanSelect", typeof(bool), typeof(MyProperties), new PropertyMetadata(true));
        public static bool GetCanSelect(DependencyObject obj)
            return (bool)obj.GetValue(CanSelectProperty);
        public static void SetCanSelect(DependencyObject obj, bool value)
            obj.SetValue(CanSelectProperty, value);

    <telerik:RadDiagramContainerShape local:MyProperties.CanSelect="false">

    For your convenience I also attached a sample project with this implementation. I hope it helps.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
  3. DevCraft R3 2016 release webinar banner
Back to Top