4
votes

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!

1
it's called caret.King King
I've also called it a caret, I think text cursor is also fine though =DChris

1 Answers

2
votes

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.)