我想捕获MouseButtons.XButton
1和2并启用向后和向前导航。
在Windows 10中,我可以使用
捕获鼠标点击this.PointerPressed += LevelsPage_PointerPressed;
private void LevelsPage_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
{
}
}
但我如何确定指针MouseButtons.XButton
或PointerRoutedEventArgs
的类型为MouseEventArgs
?一旦确定,我计划使用类似
if (pointer == MouseButton.XButton2 && this.Frame.CanGoBack)
{
this.Frame.GoBack();
e.Handled = true;
}
else if (pointer == MouseButton.XButton1 && this.Frame.CanGoForward)
{
this.Frame.GoForward();
e.Handled = true;
}
答案 0 :(得分:0)
我明白了。这是我的工作方式
private void LevelsPage_PointerPressed(object sender, PointerRoutedEventArgs e)
{
PointerPoint currentPoint = e.GetCurrentPoint(this);
if (currentPoint.PointerDevice.PointerDeviceType == PointerDeviceType.Mouse)
{
PointerPointProperties pointerProperties = currentPoint.Properties;
if (pointerProperties.IsXButton1Pressed && this.Frame.CanGoBack)
{
this.Frame.GoBack();
}
else if (pointerProperties.IsXButton2Pressed && this.Frame.CanGoForward)
{
this.Frame.GoForward();
}
}
}