I am implementing the solution described here in a MVVM project: http://nui.joshland.org/2010/04/why-wont-wpf-controls-work-with-touch.html
But the problem is that if I implement the TouchDown and TouchUp event handlers in the UserControl in my XAML then I run into a problem where other GroupView cannot get the Window Messages for flicks anymore — OR flicks are not able to be processed so their associated window message are never sent.
The top-down structure of the views is:
ButtonsView — has Touch event handlers
GroupView — has Mouse event handlers and the Flicks event handlers
I’m using this in the code-behind to hook the flicks and handle them:
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
HwndSource source = PresentationSource.FromVisual(this) as HwndSource;
source.AddHook(WndProc);
}
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (msg == Flicks.WM_TABLET_FLICK)
{
Flick flick = Flicks.ProcessMessage(lParam, wParam);
if (flick != null)
{
if (flick.Data.Direction == FLICKDIRECTION.FLICKDIRECTION_LEFT)
Scroller("left"); //scrolls left
else if (flick.Data.Direction == FLICKDIRECTION.FLICKDIRECTION_RIGHT)
Scroller("right"); //scrolls right
else if (flick.Data.Direction == FLICKDIRECTION.FLICKDIRECTION_UP)
Scroller("up"); //move up
else if (flick.Data.Direction == FLICKDIRECTION.FLICKDIRECTION_DOWN)
Scroller("down"); //move down
handled = true;
}
}
return IntPtr.Zero;
}
Thoughts/Suggestions? I’m pretty new to WPF.
Thanks
I solved this by capturing the mouse events and flick events in the ButtonsView so that they wouldn’t tunnel down to the GroupView.