C# When is TextBox.Text.Length < TextBox.SelectionStart

Viewed 720

While implementing a Behavior for a TextBox in WPF, I saw numerous examples, that use the PreviewTextInput event to handle new input. Some of the examples (e.g. techqa.info) have a condition implemented that I don't understand:

if (textBox.Text.Length < textBox.SelectionStart)
    text = textBox.Text;

From an outside perspective there is no possibility to have the selection start bigger than the length of a text in the TextBox. At most it can be at the end of the text. As the selection start is zero based, then the length and selection start must be the same value. Maybe this condition handles a special case?

0 Answers
Related