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 =
AvaloniaProperty.Register<TextBox, char>(nameof(PasswordChar));
public static readonly StyledProperty<bool> IgnoreChangesWhileEditingProperty =
AvaloniaProperty.Register<TextBox, bool>(nameof(IgnoreChangesWhileEditing));
public static readonly StyledProperty<IBrush?> SelectionBrushProperty =
AvaloniaProperty.Register<TextBox, IBrush?>(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

Loading…
Cancel
Save