我目前正在尝试将我的WPF控件传输到UWP,并且陷入了PointerMoved事件。虽然我能够检查WPF中鼠标按钮的状态并仅在状态为真时执行我的代码,但我无法弄清楚UWP中的等效项。
我在WPF中有什么
private void MyControl_MouseMove(object sender, MouseEventArgs e)
{
if (Mouse.LeftButton == MouseButtonState.Pressed)
{
//...
}
}
我想要的UWP
private void MyControl_PointerMoved(object sender, PointerRoutedEventArgs e)
{
if("PointerIsBeingPressed")
{
//...
}
}
赞赏每一个做出不同反应的答案或暗示!
答案 0 :(得分:1)
Microsoft在documentation中提供了一个示例:
private void Target_PointerMoved(object sender, PointerRoutedEventArgs e)
{
Windows.UI.Xaml.Input.Pointer ptr = e.Pointer;
if (ptr.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
{
Windows.UI.Input.PointerPoint ptrPt = e.GetCurrentPoint(Target);
if (ptrPt.Properties.IsLeftButtonPressed)
{
//Handle button press
}
}
}