I want to get the current cursor position from a WPF text box. If a TextBox contains the text abhishek and the cursor blinks after abhi , then I want this index, so later after clearing the TextBox programmatically and assigning some other or the same text programmatically, I want the cursor to flash only after 4 characters.
I tried to get a cursor position like this,
_tempFuncName = txtFunctionName.Text; _cursorPosition = txtFunctionName.SelectionStart; _selectionLength = txtFunctionName.SelectionLength;
And back to some later stage from another event like this,
txtFunctionName.Text = _tempFuncName; txtFunctionName.SelectionStart = _cursorPosition; txtFunctionName.SelectionLength = _selectionLength;
Here, underscore variables are page level variables.
This code does not work. Is there any other approach?
Abhi Oct 13 2018-11-11T00: 00Z
source share