Browse Source

Handle IsUndoEnabled in property changed

pull/6023/head
Deadpikle 5 years ago
parent
commit
b5bb89348d
  1. 23
      src/Avalonia.Controls/TextBox.cs

23
src/Avalonia.Controls/TextBox.cs

@ -464,19 +464,7 @@ namespace Avalonia.Controls
public bool IsUndoEnabled public bool IsUndoEnabled
{ {
get { return GetValue(IsUndoEnabledProperty); } get { return GetValue(IsUndoEnabledProperty); }
set set { SetValue(IsUndoEnabledProperty, value); }
{
SetValue(IsUndoEnabledProperty, value);
if (value == false)
{
// from docs at
// https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.primitives.textboxbase.isundoenabled:
// "Setting this property to false clears the undo stack.
// Therefore, if you disable undo and then re-enable it, undo commands still do not work
// because the undo stack was emptied when you disabled undo."
_undoRedoHelper.Clear();
}
}
} }
public int UndoLimit public int UndoLimit
@ -511,6 +499,15 @@ namespace Avalonia.Controls
UpdatePseudoclasses(); UpdatePseudoclasses();
UpdateCommandStates(); UpdateCommandStates();
} }
else if (change.Property == IsUndoEnabledProperty && change.NewValue.GetValueOrDefault<bool>() == false)
{
// from docs at
// https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.primitives.textboxbase.isundoenabled:
// "Setting this property to false clears the undo stack.
// Therefore, if you disable undo and then re-enable it, undo commands still do not work
// because the undo stack was emptied when you disabled undo."
_undoRedoHelper.Clear();
}
} }
private void UpdateCommandStates() private void UpdateCommandStates()

Loading…
Cancel
Save