Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Touch events not working after DoDragDrop

I am working on a WPF application that supports basic touch events (Not Manipulations). I am using Gong DragDrop to handle the drag and drop actions. The issue I ran into is described as follow:

In the [Preview] Drop event (using Gong DragDrop), I show a dialog and prompt the user to confirm the drop location, which user has to click on the "Yes" button to complete the drop or the "No" button to cancel the drop. I can use mouse to click on those two buttons, but no luck with touch events.

I have used spy++ to monitor the mouse events for the prompt dialog, which derived from a window. Both mouse events and the touch events were logged.

Why did the mouse event work and touch didn't? Is there a way to get touch to work?

like image 227
Ming Avatar asked Jan 17 '14 05:01

Ming


1 Answers

Apparently this is a bug in WPF. Microsoft have decided to ignore it and have removed the bug report which was here: https://connect.microsoft.com/VisualStudio/feedback/details/619521/wpf-touch-bug citing Connect is for future versions, not for fixing bugs source.

This MSDN Forum thread details some poor buggers attempts to deal with Microsoft on the issue. Note upgrading to .Net 4.5.1 with Visual Studio 2013 DOES NOT fix the issue.

He did however find a workaround, which is to open the dialog on a new thread.

Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(delegate
{
    var window = new MyWindowView
    {
        IsManipulationEnabled = true,
        Owner = Application.Current.MainWindow,
        Topmost = true
    };
    WindowInteropHelper helper = new WindowInteropHelper(window);
    helper.Owner = helper.Handle;
    window.ShowDialog();
}));
like image 56
JumpingJezza Avatar answered Oct 01 '22 08:10

JumpingJezza