Chris S
Chris S

Reputation: 65476

Insert at caret position with a Silverlight textbox

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?

Upvotes: 7

Views: 1197

Answers (2)

Sethles
Sethles

Reputation: 251

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; 
    }

Upvotes: 6

AnthonyWJones
AnthonyWJones

Reputation: 189555

Try:-

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

Upvotes: 5

Related Questions