AvaloniaPropertyChangedEventArgs.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using Avalonia.Data;
  3. namespace Avalonia
  4. {
  5. /// <summary>
  6. /// Provides information for a avalonia property change.
  7. /// </summary>
  8. public abstract class AvaloniaPropertyChangedEventArgs : EventArgs
  9. {
  10. public AvaloniaPropertyChangedEventArgs(
  11. IAvaloniaObject sender,
  12. BindingPriority priority)
  13. {
  14. Sender = sender;
  15. Priority = priority;
  16. IsEffectiveValueChange = true;
  17. }
  18. internal AvaloniaPropertyChangedEventArgs(
  19. IAvaloniaObject sender,
  20. BindingPriority priority,
  21. bool isEffectiveValueChange)
  22. {
  23. Sender = sender;
  24. Priority = priority;
  25. IsEffectiveValueChange = isEffectiveValueChange;
  26. }
  27. /// <summary>
  28. /// Gets the <see cref="AvaloniaObject"/> that the property changed on.
  29. /// </summary>
  30. /// <value>The sender object.</value>
  31. public IAvaloniaObject Sender { get; }
  32. /// <summary>
  33. /// Gets the property that changed.
  34. /// </summary>
  35. /// <value>
  36. /// The property that changed.
  37. /// </value>
  38. public AvaloniaProperty Property => GetProperty();
  39. /// <summary>
  40. /// Gets the old value of the property.
  41. /// </summary>
  42. public object? OldValue => GetOldValue();
  43. /// <summary>
  44. /// Gets the new value of the property.
  45. /// </summary>
  46. public object? NewValue => GetNewValue();
  47. /// <summary>
  48. /// Gets the priority of the binding that produced the value.
  49. /// </summary>
  50. /// <value>
  51. /// The priority of the new value.
  52. /// </value>
  53. public BindingPriority Priority { get; private set; }
  54. internal bool IsEffectiveValueChange { get; private set; }
  55. protected abstract AvaloniaProperty GetProperty();
  56. protected abstract object? GetOldValue();
  57. protected abstract object? GetNewValue();
  58. }
  59. }