private void Button_Click(object sender, RoutedEventArgs e) { string labelText = labelGenerator.DoLabel(); var selectionIndex = textBoxResult.SelectionStart; textBoxResult.Text = textBoxResult.Text.Insert(selectionIndex, labelText); textBoxResult.SelectionStart = selectionIndex + labelText.Length; }