Tono Nam
Tono Nam

Reputation: 36048

Caret stops blinking event in TextBox WPF

I am looking for an event that will fire when the caret of a TextBox stops blinking. Lets say I have:

<TextBox LostFocus="txtBox_LostFocus" />

In order for the event txtBox_LostFocus to be fired another control has to receive focus meanwhile that control has focus. If I click on the textbox the | starts blinking. When I click outside the textbox the | stops blinking and the LostFocus event doesn't get called why? The LostFocus event only gets called if I click on another focusable control. How can I know when the | stops blinking?

Note I call the | a cursor perhaps it has a different name.

Also

I used the Keyboard.ClearFocus(); when the user presses ENTER on the textbox to stop the Caret from blinking. This also raises the LostKeyboardFocus event!

Upvotes: 4

Views: 435

Answers (1)

Chris
Chris

Reputation: 8656

I'm not able to test it just at this second, but looking at the available events for the TextBox class on MSDN there is a LostKeyboardFocus event that sounds like it might be what you're after.

LostKeyboardFocus - Occurs when the keyboard is no longer focused on this element. (Inherited from UIElement.)

Upvotes: 2

Related Questions