From de3720ce77d181cab10be89f2f022c335b666dff Mon Sep 17 00:00:00 2001 From: ahmedmohammedfawzy <42243982+ahmedmohammedfawzy@users.noreply.github.com> Date: Thu, 9 Jun 2022 20:53:26 +0200 Subject: [PATCH] Update TextBox.cs Added the option to determine whether to ignore changes while the user is inputting or not --- src/Avalonia.Controls/TextBox.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 7652b23162..52e5da95b3 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -53,6 +53,9 @@ namespace Avalonia.Controls public static readonly StyledProperty PasswordCharProperty = AvaloniaProperty.Register(nameof(PasswordChar)); + + public static readonly StyledProperty IgnoreChangesWhileEditingProperty = + AvaloniaProperty.Register(nameof(IgnoreChangesWhileEditing)); public static readonly StyledProperty SelectionBrushProperty = AvaloniaProperty.Register(nameof(SelectionBrush)); @@ -276,6 +279,12 @@ namespace Avalonia.Controls get => GetValue(IsReadOnlyProperty); set => SetValue(IsReadOnlyProperty, value); } + + public bool IgnoreChangesWhileEditing + { + get => GetValue(IgnoreChangesWhileEditingProperty); + set => SetValue(IgnoreChangesWhileEditingProperty, value); + } public char PasswordChar { @@ -1501,7 +1510,9 @@ namespace Avalonia.Controls { try { - _ignoreTextChanges = true; + if (IgnoreChangesWhileEditing == true) + _ignoreTextChanges = true; + SetAndRaise(TextProperty, ref _text, value); } finally