Reputation: 65476
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
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
Reputation: 189555
Try:-
myTextBox.Select(position, 0);
myTextBox.SelectedText = "Content to insert";
Upvotes: 5