我开发了一个使用一些 Microsoft Surface 控件的 WPF4 触摸应用程序。我想在 ScatterViewItem 上捕获 MouseDoubleClick 事件。当我使用鼠标时会触发该事件,但是当我使用手指时,该事件永远不会引发。为什么 ?
非常感谢。
更新:
我终于编写了这段代码,以在有限的矩形(16px 宽度和高度)上重现一个简单的双击 TouchLeave 事件,并在 2 个 TouchLeave 事件之间所需的时间为 500 毫秒。这段代码没有优化,但它可以工作,如果你有什么意见,不要犹豫:)
private bool _doubleHasTimeAndPos = false;
private TimeSpan? _doubleTouchTime = null;
private Point? _doubleTouchPoint = null;
private void ScatterViewItem_TouchLeave(object sender, TouchEventArgs e)
{
if (!this._doubleHasTimeAndPos)
{
this._doubleTouchTime = DateTime.Now.TimeOfDay;
this._doubleTouchPoint = e.GetTouchPoint(this.scatterView).Position;
this._doubleHasTimeAndPos = true;
}
else
{
if (DateTime.Now.TimeOfDay.Subtract(this._doubleTouchTime.Value).TotalMilliseconds <= 500)
{
Point touchPoint = e.GetTouchPoint(this.scatterView).Position;
double xDelta = Math.Abs(this._doubleTouchPoint.Value.X - touchPoint.X);
double yDelta = Math.Abs(this._doubleTouchPoint.Value.Y - touchPoint.Y);
if (xDelta <= 16 && yDelta <= 16)
{
// DOUBLE TAP here !
}
}
this._doubleTouchTime = null;
this._doubleTouchPoint = null;
this._doubleHasTimeAndPos = false;
}
}