PointerPressed not working on left click
The solution is pretty simple: these events have to be handled not through XAML but thorugh AddHandler method.
SomeButton.AddHandler(PointerPressedEvent,
new PointerEventHandler(SomeButton_PointerPressed), true);
I have encountered this problem, but was not able to use the accepted answer because my buttons were created dynamically by an ItemsControl, and there was no good place to call AddHandler from.
Instead, I sub-classed Windows.UI.Xaml.Controls.Button:
public sealed class PressAndHoldButton : Button
{
public event EventHandler PointerPressPreview = delegate { };
protected override void OnPointerPressed(PointerRoutedEventArgs e)
{
PointerPressPreview(this, EventArgs.Empty);
base.OnPointerPressed(e);
}
}
Now, the consuming control can bind to PointerPressPreview instead of PointerPressed
<local:PressAndHoldButton
x:Name="Somebutton"
Width="100"
Height="100"
PointerPressPreview="Somebutton_PointerPressed"/>
If you want, you can stuff some additional logic in the overridden OnPointerPressed method so that it only fires the event on left-click, or right-click. Whatever you want.