PointerPressed:左或右按钮?

kar*_*tal 8 c# microsoft-metro windows-8

如何在Metro风格的C#应用​​程序中获得按下的指针类型(鼠标左键或鼠标右键)?我没有MouseLeftButtonDown 在任何Metro风格的UI元素中找到事件处理程序.我应该使用PointerPressed事件,但我不知道怎样才能得到按下的按钮.

and*_*pey 9

PointerPressed足以处理鼠标按钮:

void MainPage_PointerPressed(object sender, PointerRoutedEventArgs e)
{
    // Check for input device
    if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
    {
        var properties = e.GetCurrentPoint(this).Properties;
        if (properties.IsLeftButtonPressed)
        {
            // Left button pressed
        }
        else if (properties.IsRightButtonPressed)
        {
            // Right button pressed
        }
    }
}
Run Code Online (Sandbox Code Playgroud)