Browse Source

Update TextBox.cs

Added the option to determine whether to ignore changes while the user is inputting or not
pull/8318/head
ahmedmohammedfawzy 4 years ago
parent
commit
de3720ce77
  1. 13
      src/Avalonia.Controls/TextBox.cs

13
src/Avalonia.Controls/TextBox.cs

@ -53,6 +53,9 @@ namespace Avalonia.Controls
public static readonly StyledProperty<char> PasswordCharProperty = public static readonly StyledProperty<char> PasswordCharProperty =
AvaloniaProperty.Register<TextBox, char>(nameof(PasswordChar)); AvaloniaProperty.Register<TextBox, char>(nameof(PasswordChar));
public static readonly StyledProperty<bool> IgnoreChangesWhileEditingProperty =
AvaloniaProperty.Register<TextBox, bool>(nameof(IgnoreChangesWhileEditing));
public static readonly StyledProperty<IBrush?> SelectionBrushProperty = public static readonly StyledProperty<IBrush?> SelectionBrushProperty =
AvaloniaProperty.Register<TextBox, IBrush?>(nameof(SelectionBrush)); AvaloniaProperty.Register<TextBox, IBrush?>(nameof(SelectionBrush));
@ -276,6 +279,12 @@ namespace Avalonia.Controls
get => GetValue(IsReadOnlyProperty); get => GetValue(IsReadOnlyProperty);
set => SetValue(IsReadOnlyProperty, value); set => SetValue(IsReadOnlyProperty, value);
} }
public bool IgnoreChangesWhileEditing
{
get => GetValue(IgnoreChangesWhileEditingProperty);
set => SetValue(IgnoreChangesWhileEditingProperty, value);
}
public char PasswordChar public char PasswordChar
{ {
@ -1501,7 +1510,9 @@ namespace Avalonia.Controls
{ {
try try
{ {
_ignoreTextChanges = true; if (IgnoreChangesWhileEditing == true)
_ignoreTextChanges = true;
SetAndRaise(TextProperty, ref _text, value); SetAndRaise(TextProperty, ref _text, value);
} }
finally finally

Loading…
Cancel
Save