开发者

Tap-And-Hold Event on ScatterViewItem

I can't find infos on how 开发者_Python百科to receive custom gestures on ScatterViewItems. I want "Tap-And-Hold" to invoke a function in the class behind my template.


The following link is how to receive Touch Gestures Win32 messages using "WndProc" but the sample is in C++

http://msdn.microsoft.com/en-us/library/windows/desktop/dd371578(v=vs.85).aspx

Another method is to actually implement a Tap-Hold gesture using a simple "DispatcherTimer" which should start when the "ScatterViewItem" is touched down in the "PreviewTouchDown" event handler of the element that you want to apply the gesture on.

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();
}


TouchExtensions.AddTapGestureHandler(your_object_that_willdetect, your_handler_function);

a bit late but no harm =)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜