views:

47

answers:

1

How to raise mouse button events from code behind when we have only mouse position? I need to raise mouse events from code behind in different positions of screen.

+1  A: 

Umm.. quite simply no you can't.

Edit

Now that you've describe what it is you actually need to do (a useful techinque in getting your problems solved). Here is the solution:-

Use the AddHandler method to attach a handler for the MouseLeftButtonDown and the MouseLeftButtonUp.

myPanel.AddHandler(UIElement.MouseLeftButtonDown, MyButtonDown_Handler, true);

Note the final true parameter is the enabler here, it indicates that your handler should be called even if another element has indicated that the event has been handled.

Whilst you cannot add a handler for MouseMove in this way that is not a problem since MouseMove cannot be marked as handled anyway, so you just attach a handler to the Panel for MouseMove in the normal manner.

AnthonyWJones
Maybe you can suggest some other solution of my problem?
bgodiy
Thank you very much!
bgodiy