xkillah xkillah - 1 month ago 22
C# Question

PointerPressed not working on left click

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

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