How can I capture a tab entered in a Silverlight TextBox and render 4 spaces (or a tab) in it's place?
I can't figure out how to block the tab navigation.
How can I capture a tab entered in a Silverlight TextBox and render 4 spaces (or a tab) in it's place?
I can't figure out how to block the tab navigation.
Here is what I do (similar to Johannes' code):
This behaves just how you expect even if you select some text and hit the ol' "Tab" key.
One more thing: I tried having the tab string as "\t", but to no avail. The tab rendered, but was the width of a single space - hence the value for the Tab const being four spaces.
I am not sure how to solve your problem, I hacked together a solution though that seems to work.
Set the KeyDown event as below.
In that event I put the following code:
And then in LostFocus:
The last line in LostFocus sets the editing cursor to the end of the text, otherwise, when it gets focus, the cursor position is in the beginning of the textbox
This seemed to work well for me, and does not require the second event handler or hard coding of the text box name: