We can use pointerpressed to get the right mouse button down, but how do we get left button.
In fact, UWP has no mouseleftbuttondown, so we can use a simple way to get the left mouse button press.
We write a Button in XAML, give him the name MyButton
So we write a pointerpressed function in Xaml.cs and add it to our Button pointerpressedevent
Public MainPage ()
{this
. InitializeComponent ();
Mybutton.addhandler (pointerpressedevent,
new Pointereventhandler (button_onpointerpressed), true);
private void Button_onpointerpressed (object sender, Pointerroutedeventargs e)
{
}
If this is a breakpoint in the function, you can see that our left and right button press will trigger.
But how do we know if we pressed the left or right button.
We can use E. Handle, if it is true, then the left button, if it is false, then the right key.
This method is simple.
But this is not a good way, we can use Getcurrentpoint isleftbuttonpressed to know that we are left click
var temp = e.getcurrentpoint (sender as Button);
if (temp. properties.isleftbuttonpressed)
{
_leftmouse = true;
}
If we just left the button, then we can use the tapped
Tap can get a mouse, pressed point, which is useful when popping up.