如何通过鼠标路由事件引发Touch事件?

时间:2019-07-03 05:48:54

标签: c# wpf events touch-event

我已经找到了通过以下代码调用鼠标路由事件的解决方案:https://social.msdn.microsoft.com/Forums/vstudio/en-US/d89862b9-471e-4a3c-a26e-8c9d54e941ea/how-to-support-both-touch-event-and-mouse-event?forum=wpf

private void Button_TouchDown(object sender, TouchEventArgs e)
{
  (sender as Button).RaiseEvent(new MouseButtonEventArgs(Mouse.PrimaryDevice, e.Timestamp, MouseButton.Left) { RoutedEvent = Mouse.PreviewMouseDownEvent });
}

我想要相反的情况,所以应该是这样:

private void Button_Click(object sender, RoutedEventArgs e)
{
  (sender as Button).RaiseEvent(new TouchEventArgs() { RoutedEvent = Touch.TouchEvent });
}

但是我不知道TouchEventArgs的三个参数应该是什么。另外,我不确定RoutedEvent。有人可以帮忙吗?

0 个答案:

没有答案