ScatterViewItemsでカスタムジェスチャを受信する方法に関する情報が見つかりません。「Tap-And-Hold」でテンプレートの背後にあるクラスの関数を呼び出したい。
2 に答える
0
次のリンクは、「WndProc」を使用してタッチ ジェスチャ Win32 メッセージを受信する方法ですが、サンプルは C++ です。
http://msdn.microsoft.com/en-us/library/windows/desktop/dd371578(v=vs.85).aspx
もう 1 つの方法は、ジェスチャを適用する要素の「PreviewTouchDown」イベント ハンドラで「ScatterViewItem」がタッチダウンされたときに開始する単純な「DispatcherTimer」を使用して、タップ ホールド ジェスチャを実際に実装することです。
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();
}
于 2011-12-14T10:46:30.723 に答える