locked
PointerPressed event not firing on Button RRS feed

  • Question

  • I'm trying to use the PointerPressed event on buttons for my WPF WinRT app but it seems this event never fires. Is there something special I need to do? 
    Tuesday, September 11, 2012 7:58 PM

Answers

  • Ah, i changed the button ClickMode to "Pressed" instead of default "released". Now I can use "Click" for pressed event.
    • Proposed as answer by jippers Wednesday, September 12, 2012 6:11 PM
    • Marked as answer by Jie Bao Wednesday, September 26, 2012 6:10 AM
    Wednesday, September 12, 2012 6:11 PM
  • That doesn't make sense. You don't have to explicitly set the ClickMode to pressed just to fire the Click event, and he was referring to the PointerPressed event not Click, event. PointerPress will only fire if you right click on it not left click. 
    • Marked as answer by Jie Bao Wednesday, September 26, 2012 6:10 AM
    Thursday, September 13, 2012 1:12 AM

All replies

  • I don't know what the reason might be but the PointerPressed is being fired if you use the right click instead of left click. So I am guessing that someone else is handling the left click event.

    In general you should handle the Click event for Buttons instead of PointerPressed.

    The Button control handles the PointerPressed event internally to implement its hover/click behavior and marks the PointerPressed routed event as handled - this means the event will not be bubbled up to your handler by default.

    There's an overview of the routed events model and its interaction with controls here, under the "Input Event Handlers in Controls":

    http://msdn.microsoft.com/en-us/library/cc189018(v=VS.95).aspx

    • Proposed as answer by Leo LuisMVP Thursday, September 13, 2012 1:11 AM
    Wednesday, September 12, 2012 3:31 AM
  • Ah, i changed the button ClickMode to "Pressed" instead of default "released". Now I can use "Click" for pressed event.
    • Proposed as answer by jippers Wednesday, September 12, 2012 6:11 PM
    • Marked as answer by Jie Bao Wednesday, September 26, 2012 6:10 AM
    Wednesday, September 12, 2012 6:11 PM
  • That doesn't make sense. You don't have to explicitly set the ClickMode to pressed just to fire the Click event, and he was referring to the PointerPressed event not Click, event. PointerPress will only fire if you right click on it not left click. 
    • Marked as answer by Jie Bao Wednesday, September 26, 2012 6:10 AM
    Thursday, September 13, 2012 1:12 AM
  • How do you use the WinRT in WPF, and use WinRT pointer events. Does this a Windows Store app or a WPF desktop app?

    If it is a WPF application, please use Mouse events, Touch events and Manipulation events to handle the mouse, and touch actions.

    If it is a Windows Store app, for Button, please use Click instead. (In WPF, we also need the Click event)

    And please continue to discuss the Windows Store app development questions on our Windows Store apps forums http://social.msdn.microsoft.com/Forums/en-US/category/windowsapps


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, September 26, 2012 6:10 AM
  • Alternatively, put the button inside a border. This border should be transparent and the Thickness should be half of the Width. Then set IsHitTestVisible to false for the button and true for the border. Then use the PointerXxxxx events for the border.

    Paul Cotter

    Monday, May 1, 2017 1:45 PM