Reputation: 1512
Is there any way to detect a right click event from a mouse when using Xamarin for a UWP app? There does not seem to be any way to access mouse events except as they simulate touch events.
Upvotes: 1
Views: 914
Reputation: 3251
If this is just a pure UWP app there is a UIElement.PointerPressed
Event you can subscribe to.
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.IsRightButtonPressed)
{
// Do something
}
// Prevent most handlers along the event route from handling the same event again.
e.Handled = true;
}
}
Check out the docs for more info.
Upvotes: 1