diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index b561a3423f..387af58255 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -316,8 +316,7 @@ namespace Avalonia.Controls !AcceptsReturn && Text?.Length > 0) { - SelectionStart = 0; - SelectionEnd = Text.Length; + SelectAll(); } else { @@ -673,8 +672,7 @@ namespace Avalonia.Controls SelectionEnd = StringUtils.NextWord(text, index); break; case 3: - SelectionStart = 0; - SelectionEnd = text.Length; + SelectAll(); break; } } @@ -896,7 +894,10 @@ namespace Avalonia.Controls CaretIndex = caretIndex; } - private void SelectAll() + /// + /// Select all text in the TextBox + /// + public void SelectAll() { SelectionStart = 0; SelectionEnd = Text?.Length ?? 0;