简体   繁体   中英

GotFocus and LostFocus Events in WPF TextBox

I have a textBox control in a WPF window. I have separate handlers for GotFocus and LostFocus events. But when the textbox attains focus for the first time LostFocus is invoked after GotFous (The textbox loses focus as soon as it attains focus for the first time) . But this doesn't happen when the textBox attains focus for the second time.

Sounds like maybe something is happening during the GotFocus event handler (or deeper in the call stack) that is relinquishing focus to another control.

You might want to try setting a breakpoint in your LostFocus event handler and then look at the call stack to see if something is setting the focus elsewhere either directly or indirectly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM