WPF control does not capture the press and hold event (right click) when IsManipulationEnabled is set

StackOverflow https://stackoverflow.com/questions/3085431

Question

I'm starting to make some tests with a touch screen and I've found that if a UIControl has the "IsManipulationEnabled" attribute set to true then the MouseRightClick Events fired by the press and hold gesture (WIN7) is not captured. Am I doing something wrong?

public MainWindow()
    {
        InitializeComponent();
        WC_Rectangle.IsManipulationEnabled = true;
        WC_Rectangle.MouseRightButtonUp += new MouseButtonEventHandler(WC_Rectangle_MouseRightButtonUp);
    }

    void WC_Rectangle_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
    {
        System.Diagnostics.Debug.WriteLine("RIGHT CLICK : " + sender.ToString());
    }
Was it helpful?

Solution

After setting IsManipulationEnabled = true; all touchevents are captured and handled by the WC_Rectangle which does transform them to Manipulation events. So the touchevents do not tunnel back to the control that raised them which in turn means the control can't promote unhandled touch events to mouse events (the default). see:

http://nui.joshland.org/2010/04/why-wont-wpf-controls-work-with-touch.html

OTHER TIPS

If you cancel the manipulation events you should get the mouse events.

Use Behavior Instead

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top