ErrorCollectingTextBox.cs 699 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using Avalonia.Controls;
  3. using Avalonia.Data;
  4. #nullable enable
  5. namespace Avalonia.Base.UnitTests.Data.Core;
  6. /// <summary>
  7. /// A <see cref="TextBox"/> which stores the latest binding error state.
  8. /// </summary>
  9. public class ErrorCollectingTextBox : TextBox
  10. {
  11. public Exception? Error { get; private set; }
  12. public BindingValueType ErrorState { get; private set; }
  13. protected override void UpdateDataValidation(AvaloniaProperty property, BindingValueType state, Exception? error)
  14. {
  15. if (property == TextProperty)
  16. {
  17. Error = error;
  18. ErrorState = state;
  19. }
  20. base.UpdateDataValidation(property, state, error);
  21. }
  22. }