Capture mouse clicks on WPF TextBox

前端 未结 3 965
星月不相逢
星月不相逢 2021-02-03 21:25

I want to capture mouse clicks on a TextBox:



        
3条回答
  •  北荒
    北荒 (楼主)
    2021-02-03 21:33

    TextBox Class

    TextBox has built-in handling for the bubbling MouseUp and MouseDown events. Consequently, custom event handlers that listen for MouseUp or MouseDown events from a TextBox will not be called. If you need to respond to these events, listen for the tunneling PreviewMouseUp and PreviewMouseDown events instead, or register the handlers with the HandledEventsToo argument (this latter option is only available through code). Do not mark the event handled unless you deliberately want to disable TextBox native handling of these events, and be aware that this has notable effects on the control's UI.

    In you code you are firing just MouseLeftButtonUp

提交回复
热议问题