I'm trying to remove caret blinking from a textbox after the input is done. I've tried focusing another control programmatically and setting IsReadOnlyCaretVisible=false and IsReadOnly on mouseleave event but nothing helps. What should I do? The caret still remains there whatever I do...
Asked
Active
Viewed 1,492 times
0
-
What do you mean by "after the input is done"? Isn't that only guaranteed to be the case when the user changes focus to another control? – djdanlib Oct 18 '11 at 16:09
-
I've entered the text I wanted – OneMoreVladimir Oct 18 '11 at 16:13
-
But how does the control know what you want? A user could want to enter anything, even no text at all. – djdanlib Oct 18 '11 at 16:24
-
What determines when input is finished? Are you hitting the Enter key or are you filling the text programmatically? – Yatrix Oct 18 '11 at 17:26
-
I hit the enter key or click out of the textbox – OneMoreVladimir Oct 18 '11 at 17:29
-
Are you sure the control has actually lost focus or that focus has not gone back to it for some reason? – Yatrix Oct 18 '11 at 18:14
1 Answers
2
That's very strange. The caret should go away when the focus changes, eg when you click out of the textbox. You can't use the old fashioned "HideCaret" WINAPI function, since it's not a standard Windows control - it's WPF.
This question addresses the OPPOSITE of your problem, since your problem isn't supposed to even happen, and the solution was a very simple line of code. Perhaps if you flip the logic around, or find out if your code is already doing this and disable that part - you can get the result you're looking for: WPF Textbox persist visible caret
Also, if you're using a recent version of WPF, you can probably reassign the brush that the caret uses.
-
Ive created a usercontrol with a textbox and I'm adding those controls to Canvas. When I edit the text and then click on canvas or wherever the caret still remains blinking in the textbox... =( – OneMoreVladimir Oct 18 '11 at 18:21