private void ReplaceCurrentLineText(string newText) { var caretIndex = CommandLineBox.CaretIndex; var lineIndex = CommandLineBox.GetLineIndexFromCharacterIndex(caretIndex); var characterIndex = CommandLineBox.GetCharacterIndexFromLineIndex(lineIndex); var textOnLine = CommandLineBox.GetLineText(lineIndex); CommandLineBox.Select(characterIndex, textOnLine.Length); CommandLineBox.SelectedText = newText; CommandLineBox.Focus(); CommandLineBox.Select(CommandLineBox.Text.Length, 0); CommandLineBox.ScrollToLine(lineIndex); }
private void CommandLineBox_OnLoaded(object sender, RoutedEventArgs e) { CommandLineBox.Focus(); CommandLineBox.CaretIndex = CommandLineBox.Text.Length; }