We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Mouse events for DiagramControl

Thread ID:





115346 Jan 10,2014 04:38 PM UTC Jan 21,2014 06:14 AM UTC WPF 6
Tags: Diagram
Domenico Mozzone
Asked On January 10, 2014 04:38 PM UTC

Good Morning,
I'm using version of WPF diagram.
I'm trying to hook mouse events like MouseDown, MouseLeftButtonDown but with the canonical operation
DiagramControlMain.MouseLeftButtonDown += DiagramControlMainOnMouseLeftButtonDown;

the DiagramControlMainOnMouseLeftButtonDown handler is not call on the related action of mouse.

I tried also with the provided DiagramBuilder example project with the same result.

Where's my error?

Best Regards

Domenico Mozzone

Domenico Mozzone
Replied On January 10, 2014 04:41 PM UTC

I'm sorry I forgot to ask the way to change the Mouse Cursor on DiagramControl.
Thanks in advance
Best regards

Domenico Mozzone
Replied On January 10, 2014 05:14 PM UTC

..last thing and then I hope to stop boring you.
How can I get coordinates in the Diagram reference system of a mouse click (actually a double click as is the only event I was able to connect)?
I tried 
var position = mouseButtonEventArgs.GetPosition(null);
but such position seems to be referred to the top left corner.

Best regards

Domenico Mozzone
Replied On January 13, 2014 07:52 AM UTC

don't mind the last question, I solved.
var position = mouseButtonEventArgs.GetPosition(DiagramView);
                if (this.HorizontalRuler.Visibility == Visibility.Visible)
                    position.Y -= this.HorizontalRuler.ActualHeight;
                if (this.VerticalRuler.Visibility == Visibility.Visible)
                    position.X -= this.VerticalRuler.ActualWidth;

Thank you

Parthiban A [Syncfusion]
Replied On January 16, 2014 06:29 AM UTC

Hi Domenico,

Diagram controls MouseLeftButtonDown event is used for internal purpose. So you can use Addhandler method to hook new event handler. Kindly find the code snippet below,

DiagramControl diagramcontrol=new DiagramControl();

            diagramcontrol.AddHandler(MouseLeftButtonDownEvent, new RoutedEventHandler(OnMouseLeftButtonDown), true);


private void OnMouseLeftButtonDown(object sender, RoutedEventArgs e)


   System.Windows.Forms.Cursor.Position = new System.Drawing.Point(0, 0);


To change the mouse cursor dynamically, kindly find the code snippet below

System.Windows.Forms.Cursor.Position = new System.Drawing.Point(0, 0);

Note : Need to add System.Windows.Forms and System.Drawing dll


Parthiban A.

Domenico Mozzone
Replied On January 16, 2014 09:38 AM UTC

Hi Parthiban,
Thank you for your help.
My need is to:
1. Change the mouse pointer shape from default to cross for example and viceversa,
2. Intercept the mouseDown of left button (solved with your help)
3. Get mouse coordinates in the(x,y) diagram reference system

Number 2 is ok, thanks to your help, but 1 and 3 I think that I didn't succeed in explaning the requirements.
Hope that now is clearer

Kind regards.
Domenico M

Parthiban A [Syncfusion]
Replied On January 21, 2014 06:14 AM UTC

Hi Domenico,

Kindly find the responses below,





Change the mouse pointer shape from default to cross for example and viceversa,

We can change the pointer shape by setting type for Cursor property. But couldn’t set pointer type for diagram control objects like node, connector, diagram page. Since those are set by internally. However we can set cursor for any framework element. We have created sample in which set button as node, while drag and drop from the palette. When mouse over that button, cursor changed to Hand.

For more information please refer the provided sample.


Code Snippet:

(sender as Button).Cursor = Cursors.Hand;



Get mouse coordinates in the(x,y) diagram reference system

Mouse.GetPosition method will return the mouse co-ordinates with respect to the IInputElement. We have created a sample, which will show the mouse co-ordinates while double clicking on the diagram control.


void view_MouseDoubleClick(object sender, MouseButtonEventArgs e)

        {    MessageBox.Show(Mouse.GetPosition(view).ToString());




Parthiban A.




This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon