Controlling the position of Silverlight textbox's caretbrush - silverlight

I believe the cursor over a textbox is called a caretbrush.
There are times application is run without a keyboard/ mouse (eg: Kiosk), so I will put up a virtual keyboard for the user.
The virtual keyboard appends to the textbox programmatically.
When I focus on the textbox, irregardless of have any text in it, the caretbrush will always be at the leftmost position.
Is there anyway I can control the position of it?
If unable to do it, guess I just hide the caret brush, otherwise it looks abit confusing especially when u are at the 3rd character but the caretbrush shows on the 1st character.

I found the answer already.
txt1.SelectionStart=txt1.text.length

but txt1.SelectionStart=txt1.text.length-1 is only correct

Related

How to disable "select all" in a WPF TextBox

On mouseclick on a WPF TextBox, the textbox gets the focus and selects all the text.
How I can this disable this behavior? On click only the caret shall be positioned on the char (as in good old windows).
Why? If I click on a textbox i want to mark some text, or set the carret position, to type more text. I do not want to deselect the whole marked text first and then click on the position again.
Another thing is, when the window lost the focus and get it back, the whole text is selected again and the carret position is lost. So it is not possible to copy text from another window and paste to the textbox w/o to select the correct carret position again.
Maybe this is a system "feature" (W8.1/W10) because non WPF textboxes have the same behavior, but this is annoying. Thanks for your helping ideas.
My text box does not do this by default, The only one thing what i have done with it just bind TextBox.Text property with my ViewModel's property
Here described the mechanism of things that you have mentioned above, you just need to revert them
https://social.msdn.microsoft.com/Forums/vstudio/en-US/564b5731-af8a-49bf-b297-6d179615819f/how-to-selectall-in-textbox-when-textbox-gets-focus-by-mouse-click?forum=wpf

Silverlight RTL Support

I know Silverlight 4 added support for RTL languages through the FlowDirection property.
Being new to RTL I just want to make sure I understand what should happen when I set the FlowDirection property. I noticed that the text alignment for the TextBoxes are now right aligned and the whole UI basically mirrors itself by switching everything that was on the left over to the right. So this all seems to be working fine. However, when entering text in a Textbox, surely the text should complete from right to left now as well. So I if enter the word 'run' in a TextBox with FlowDirection set to RTL, then surely it should read 'nur' and not 'run'? Is my understanding correct, but currently the TextBox still displays it as 'run' even thought it is right-aligned in the control itself.
The RTL-ness of the text will be automatically by the unicode text itself. So if you chuck in some Arabic text into the TextBox, it'll be in the correct direction (RTL), regardless of whether the FlowDirection is set or not. The FlowDirection is just for mirroring the UI, it's not about changing the text. Apparently there's also some clever special treatment of colons.
So basically: yup, that's correct, working as intended.

wpf textbox caret

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

Difference between Control.Focus() and FocusManager.SetFocusedElement()

Literally, I want to know that.
In some case, .Focus() appear better than SetFocusedElement(). But another case, it's reversal. So I must know what's different things are there.
Additionally, by MSDN, .Focus() is for keyboard focus, and SetFocusedElement is for logical focus. But I can't feel different thing between logical focus and keyboard focus.
The keyboard focus is generally easier to understand, as that is effectively the control that would receive keyboard input if the user typed. So if you click in a TextBox it will receive keyboard focus and you can start typing. Other controls have other behaviors and may not really support the keyboard, but they can still get the keyboard focus.
For logical focus, your application can be made up of several parts. For example, most applications would have a ToolBar/Ribbon at the top and then their main content below. Now, imagine that your content is a TextBox that currently has the keyboard focus. When you click in a ToolBar/Ribbon control, the keyboard focus is moved to that control. But you really want to "remember" that the TextBox in your content had the keyboard focus before.
To achieve this the ToolBar/Ribbon will create new "focus scope". So when you click in the ToolBar/Ribbon control, you move the keyboard focus but the TextBox still has the logical focus for the window. That allows the TextBox to be given the keyboard focus back when the user is done working with the ToolBar/Ribbon.
The same holds true if you interact with another application, as your application doesn't have the keyboard focus. When you go back to working in your application, it uses the logical focus to know who had keyboard focus last (and should have it restored).
Using FocusManager.SetFocusedElement(), you can specify a UserControl of which you want to set focus on an element. So you can set focus on a control that is in a different part of your program.
Control.Focus() is just straightforward, you set focus on the said control (which is more intuitive).
Wild guess: you use FocusManager.SetFocusedElement() improperly, resulting in unwanted behaviors but bottom line, it's the same thing really.
Sidenote: "logical" focus and "keyboard" focus are 2 different things in WPF.

Make a textbox not blink?

I am trying to get a control i can click on, press any keys (except tab) and have it take in the input. I tried using this and had a problem with the arrow keys changing the focus. That question is here.
The textbox seems to work but i dont like how it blinks. As in the line that shows where you next letter will be placed. How do i fix this?
Blinking is a system wide option. Check this out.
If you create a UserControl based on the standard textbox you can use [Control::IsInputKey][1] to override default behaviour which causes the control to lose focus.

Resources