[UWP][C#] How to handle the mouse/pointer events for readonly TextBoxes RRS feed

  • Question

  • Hi All,

    I am developing an UWP application wherein I need to put multiple readonly TextBoxes and I want to handle the mouse/pointer events of these TextBoxes so that I can display a popup on it.

    I have already tried to handle Tapped, PointerPressed and GotFocus events but none of these are fired.

    Please help....


    Prashant Srivastava

    Thursday, December 1, 2016 11:02 AM


  • Hi PrashantSrivastava,

    It seems when we set the PointerPressed in XAML that will not work.

    Specific Windows Runtime controls may have class-based handling for the PointerPressed input event. If so, the control probably has an override for the method OnPointerPressed. Typically the event is marked handled by the class handler, and the PointerPressed event is not raised for handling by any user code handlers on that control. For example, ButtonBase has class handling that handles PointerPressed and instead fires Click. For more info on how class-based handling for events works, see Events and routed events overview.

    For more info, see UIElement.PointerPressed.

    We should be able to use  the AddHandler method.

    For example:

    public MainPage()
        MyTextBox.AddHandler(PointerPressedEvent, new PointerEventHandler(TextBox_PointerPressed), true);
    private void TextBox_PointerPressed(object sender, PointerRoutedEventArgs e)

    Best Regards,

    Jayden Gu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 2, 2016 6:20 AM