我无法找到有关如何在Scatter View Items上接收自定义手势的信息。我希望“Tap-And-Hold”在模板后面的类中调用一个函数。
答案 0 :(得分:0)
以下链接是如何使用“WndProc”接收Touch Gestures Win32消息,但示例是使用C ++
http://msdn.microsoft.com/en-us/library/windows/desktop/dd371578(v=vs.85).aspx
另一种方法是使用简单的“DispatcherTimer”实际实现一个Tap-Hold手势,该“DispatcherTimer”应该在您要应用手势的元素的“PreviewTouchDown”事件处理程序中触及“ScatterViewItem”时启动。
void OnPreviewTouchDown(object sender, System.Windows.Input.TouchEventArgs e)
{
if(e.Source.GetHashCode() == YourUIElement.GetHashCode() )
{
MyTimer.Start();
//You need to capture the touch before the ScatterViewItem handles its own touch which will
//block you from receiving the touch up event
YourUIElement.CaptureTouch(e.TouchDevice);
e.Handled = true;
}
}
void OnPreviewTouchUp(object sender, System.Windows.Input.TouchEventArgs e)
{
YourUIElement.ReleaseAllTouches();
}
private void OnTimerTick(object sender, EventArgs e)
{
// To call whatever function or do whatever action you need.
IsTapHoldGestureOkay = true;
DoStuff();
MyTimer.Stop();
}
答案 1 :(得分:0)
TouchExtensions.AddTapGestureHandler(your_object_that_willdetect, your_handler_function);
有点晚但没有伤害=)