PointerPressed not working on left click

xkillah picture xkillah · Feb 8, 2013 · Viewed 7.1k times · Source

Creating Metro (Microsoft UI) app for Windows 8 on WPF+C#, I met difficulty with PointerPressed event on a button. Event doesn't happen when i perform left-click (by mouse), but it happens in case with right-click or tap. So what's wrong with that event? for example

 <Button x:Name="Somebutton"  Width="100" Height="100"
PointerPressed="Somebutton_PointerPressed"/>

Answer

xkillah picture xkillah · Feb 11, 2013

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);