0

Based on some characters I need to position cursor in between the text or at the end of text when the user clicks on to that textbox control in WPF. Any idea how to achieve this?

Almir Vuk
  • 2,983
  • 1
  • 18
  • 22
Prasad
  • 93
  • 8
  • 1
    Possible duplicate of http://stackoverflow.com/questions/2888907/set-the-caret-cursor-position-to-the-end-of-the-string-value-wpf-textbox –  Aug 10 '16 at 09:49

2 Answers2

0

NumberOfDigits.CaretIndex = Where you want it to be
So you gotta find out at which position these "characters" are.

hYg-Cain
  • 348
  • 3
  • 10
0

Set the CaretIndex to the end of input like this :

TextBoxName.CaretIndex = TextBoxName.Text.Length - 1;

or to the middle of text like this :

TextBoxName.CaretIndex = TextBoxName.Text.Length / 2;
ViVi
  • 4,339
  • 8
  • 29
  • 52