From fd656d29d8652816d37a5f116b51ef447ccc89e8 Mon Sep 17 00:00:00 2001 From: Dmitry Zhelnin Date: Mon, 17 May 2021 16:34:00 +0300 Subject: [PATCH] TextBox: update command states on selection changes --- src/Avalonia.Controls/TextBox.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 69da667011..15a954b462 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -260,7 +260,11 @@ namespace Avalonia.Controls set { value = CoerceCaretIndex(value); - SetAndRaise(SelectionStartProperty, ref _selectionStart, value); + var changed = SetAndRaise(SelectionStartProperty, ref _selectionStart, value); + if (changed) + { + UpdateCommandStates(); + } if (SelectionStart == SelectionEnd) { CaretIndex = SelectionStart; @@ -278,7 +282,11 @@ namespace Avalonia.Controls set { value = CoerceCaretIndex(value); - SetAndRaise(SelectionEndProperty, ref _selectionEnd, value); + var changed = SetAndRaise(SelectionEndProperty, ref _selectionEnd, value); + if (changed) + { + UpdateCommandStates(); + } if (SelectionStart == SelectionEnd) { CaretIndex = SelectionEnd;