Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 238
Chris S Avatar asked Jun 11 '10 10:06

Chris S


2 Answers

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; 
    }
like image 195
Sethles Avatar answered Oct 22 '22 17:10

Sethles


Try:-

 myTextBox.Select(position, 0);
 myTextBox.SelectedText = "Content to insert";
like image 5
AnthonyWJones Avatar answered Oct 22 '22 17:10

AnthonyWJones