7
votes

In WPF you can insert at the caret position using the CaretIndex property. However this seems to be missing in the Silverlight textbox control.

Is it possible using a different technique?

2

2 Answers

6
votes

I also had the same problem. I used the SelectionStart property.

    private void QuotePrefixTextboxTextChanged(object sender, TextChangedEventArgs e)
    {
        var tb = (TextBox)sender;
        var caret = tb.SelectionStart;
        tb.Text = tb.Text.ToUpper();
        tb.SelectionStart = caret; 
    }
5
votes

Try:-

 myTextBox.Select(position, 0);
 myTextBox.SelectedText = "Content to insert";