This project is read-only.

How disable Blake.NUI.WPF.Touch.MouseTouchDevice.RegisterEvents(this);

Jan 4, 2012 at 8:40 AM
Edited Jan 4, 2012 at 6:57 PM




Hello, i no want use registermouse touch device in the constructor.
On my software i need just run in some specific moment not all time.
Only need add mouse support only in specific time.

I run this at runtime in any moment


And that work, i run out of cosntuctor and work.
But then if I want disable for back to standar and normal work........ 
How disable or make Blake.NI.WPF.Touch stop catch events and back all to normal? Hoppe can undersatnd what I try explain. Is possible? How?

Another question I have is when use this:

private void TouchDown(object sender, TouchEventArgs e)
    if (e.TouchDevice is MouseTouchDevice)
        //Do something specific for the mouse

Is possible, know if mouse event is left click, or right click, if down or up etc etc?










Jan 4, 2012 at 7:33 PM

To unregister, you'll have to add a method to MouseTouchDevice.

The RegisterEvents method looks like this:

public static void RegisterEvents(FrameworkElement root)
    root.PreviewMouseDown += MouseDown;
    root.PreviewMouseMove += MouseMove;
    root.PreviewMouseUp += MouseUp;

You'll want to add this method into the MouseTouchDevice class:

public static void UnregisterEvents(FrameworkElement root)

    root.PreviewMouseDown -= MouseDown;
    root.PreviewMouseMove -= MouseMove; 
    root.PreviewMouseUp -= MouseUp;

If you need to know whether a click is left or right click, then you may not want to use MouseTouchDevice after all. If you must, though, then you add a property like:

public MouseDevice MouseDevice { get; private set; }

then in the MouseTouchDevice.MouseDown method, save e.MouseDevice to the property:

this.MouseDevice = e.MouseDevice;

If you wanted to only promote left mouse clicks to touch, or some other rules, you could add a check for the e.MouseDevice.LeftButton or e.MouseDevice.RightButton in the MouseDown method first. You'd have to do some testing though to make sure it behaves as you desire if the user left clicks for touch promotion then also right clicks while the left button is still down, and other scenarios.

Hope that gives you enough information to get going!


Jan 4, 2012 at 9:14 PM
Edited Jan 5, 2012 at 12:51 AM

Thank you so much for your reply.
I try compile your lib, wit that change, im very new in C# and WPF but after some errors adn after delete copy path i not have more errors.
And can compile, i added inside the MouseTouchDevice.cs your new code and now look like this:

Public Static Methods

public static void RegisterEvents(FrameworkElement root)


root.PreviewMouseDown += MouseDown;

root.PreviewMouseMove += MouseMove;

root.PreviewMouseUp += MouseUp;



public static void UnregisterEvents(FrameworkElement root)


root.PreviewMouseDown -= MouseDown;

root.PreviewMouseMove -= MouseMove;

root.PreviewMouseUp -= MouseUp;


After this is implemented, all what I have to do is run
Blake.NUI.WPF.Touch.MouseTouchDevice.UnregisterEvents(form);  correct?

Well not work!
When i run Blake.NUI.WPF.Touch.MouseTouchDevice.RegisterEvents(form);

All work perfect mouse events are translated as touch events.

But then i run Blake.NUI.WPF.Touch.MouseTouchDevice.UnregisterEvents(form); and now,  no Have response again to all mouse events, by example, right mouse click not work more over that form, this never work again:

private void MouseRightButtonDown(object sender, MouseButtonEventArgs e)





Some idea?

Jan 5, 2012 at 11:11 AM

Thank you again!!
After some work I have all fixed!!

Best regards !!