IAvaloniaObject.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using Avalonia.Data;
  5. namespace Avalonia
  6. {
  7. /// <summary>
  8. /// Interface for getting/setting <see cref="AvaloniaProperty"/> values on an object.
  9. /// </summary>
  10. public interface IAvaloniaObject
  11. {
  12. /// <summary>
  13. /// Raised when a <see cref="AvaloniaProperty"/> value changes on this object.
  14. /// </summary>
  15. event EventHandler<AvaloniaPropertyChangedEventArgs> PropertyChanged;
  16. /// <summary>
  17. /// Raised when an inheritable <see cref="AvaloniaProperty"/> value changes on this object.
  18. /// </summary>
  19. event EventHandler<AvaloniaPropertyChangedEventArgs> InheritablePropertyChanged;
  20. /// <summary>
  21. /// Gets a <see cref="AvaloniaProperty"/> value.
  22. /// </summary>
  23. /// <param name="property">The property.</param>
  24. /// <returns>The value.</returns>
  25. object GetValue(AvaloniaProperty property);
  26. /// <summary>
  27. /// Gets a <see cref="AvaloniaProperty"/> value.
  28. /// </summary>
  29. /// <typeparam name="T">The type of the property.</typeparam>
  30. /// <param name="property">The property.</param>
  31. /// <returns>The value.</returns>
  32. T GetValue<T>(AvaloniaProperty<T> property);
  33. /// <summary>
  34. /// Checks whether a <see cref="AvaloniaProperty"/> is animating.
  35. /// </summary>
  36. /// <param name="property">The property.</param>
  37. /// <returns>True if the property is animating, otherwise false.</returns>
  38. bool IsAnimating(AvaloniaProperty property);
  39. /// <summary>
  40. /// Checks whether a <see cref="AvaloniaProperty"/> is set on this object.
  41. /// </summary>
  42. /// <param name="property">The property.</param>
  43. /// <returns>True if the property is set, otherwise false.</returns>
  44. bool IsSet(AvaloniaProperty property);
  45. /// <summary>
  46. /// Sets a <see cref="AvaloniaProperty"/> value.
  47. /// </summary>
  48. /// <param name="property">The property.</param>
  49. /// <param name="value">The value.</param>
  50. /// <param name="priority">The priority of the value.</param>
  51. void SetValue(
  52. AvaloniaProperty property,
  53. object value,
  54. BindingPriority priority = BindingPriority.LocalValue);
  55. /// <summary>
  56. /// Sets a <see cref="AvaloniaProperty"/> value.
  57. /// </summary>
  58. /// <typeparam name="T">The type of the property.</typeparam>
  59. /// <param name="property">The property.</param>
  60. /// <param name="value">The value.</param>
  61. /// <param name="priority">The priority of the value.</param>
  62. void SetValue<T>(
  63. AvaloniaProperty<T> property,
  64. T value,
  65. BindingPriority priority = BindingPriority.LocalValue);
  66. /// <summary>
  67. /// Binds a <see cref="AvaloniaProperty"/> to an observable.
  68. /// </summary>
  69. /// <param name="property">The property.</param>
  70. /// <param name="source">The observable.</param>
  71. /// <param name="priority">The priority of the binding.</param>
  72. /// <returns>
  73. /// A disposable which can be used to terminate the binding.
  74. /// </returns>
  75. IDisposable Bind(
  76. AvaloniaProperty property,
  77. IObservable<object> source,
  78. BindingPriority priority = BindingPriority.LocalValue);
  79. /// <summary>
  80. /// Binds a <see cref="AvaloniaProperty"/> to an observable.
  81. /// </summary>
  82. /// <typeparam name="T">The type of the property.</typeparam>
  83. /// <param name="property">The property.</param>
  84. /// <param name="source">The observable.</param>
  85. /// <param name="priority">The priority of the binding.</param>
  86. /// <returns>
  87. /// A disposable which can be used to terminate the binding.
  88. /// </returns>
  89. IDisposable Bind<T>(
  90. AvaloniaProperty<T> property,
  91. IObservable<T> source,
  92. BindingPriority priority = BindingPriority.LocalValue);
  93. }
  94. }