捕获鼠标按钮。XButton1/2 用于 Forward/Backward 导航 Windows 10

Capture MouseButtons.XButton1/2 for Forward/Backward navigation Windows 10

我想捕获 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;
        }

我明白了。这是我的做法

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

    }