diff --git a/src/Avalonia.Visuals/Media/DrawingImage.cs b/src/Avalonia.Visuals/Media/DrawingImage.cs
index 9ce6ecd9e7..d6ab004dd7 100644
--- a/src/Avalonia.Visuals/Media/DrawingImage.cs
+++ b/src/Avalonia.Visuals/Media/DrawingImage.cs
@@ -1,14 +1,27 @@
-using Avalonia.Metadata;
+using System;
+using Avalonia.Metadata;
using Avalonia.Platform;
using Avalonia.Visuals.Media.Imaging;
namespace Avalonia.Media
{
- public class DrawingImage : AvaloniaObject, IImage
+ ///
+ /// An that uses a for content.
+ ///
+ public class DrawingImage : AvaloniaObject, IImage, IAffectsRender
{
+ ///
+ /// Defines the property.
+ ///
public static readonly StyledProperty DrawingProperty =
AvaloniaProperty.Register(nameof(Drawing));
+ ///
+ public event EventHandler Invalidated;
+
+ ///
+ /// Gets or sets the drawing content.
+ ///
[Content]
public Drawing Drawing
{
@@ -16,9 +29,11 @@ namespace Avalonia.Media
set => SetValue(DrawingProperty, value);
}
+ ///
public Size Size => Drawing?.GetBounds().Size ?? default;
- public void Draw(
+ ///
+ void IImage.Draw(
DrawingContext context,
Rect sourceRect,
Rect destRect,
@@ -45,5 +60,22 @@ namespace Avalonia.Media
Drawing?.Draw(context);
}
}
+
+ ///
+ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs e)
+ {
+ base.OnPropertyChanged(e);
+
+ if (e.Property == DrawingProperty)
+ {
+ RaiseInvalidated(EventArgs.Empty);
+ }
+ }
+
+ ///
+ /// Raises the event.
+ ///
+ /// The event args.
+ protected void RaiseInvalidated(EventArgs e) => Invalidated?.Invoke(this, e);
}
}