diff --git a/src/Avalonia.Svg.Skia/SvgImage.cs b/src/Avalonia.Svg.Skia/SvgImage.cs index 30c1cded..10d27b71 100644 --- a/src/Avalonia.Svg.Skia/SvgImage.cs +++ b/src/Avalonia.Svg.Skia/SvgImage.cs @@ -1,4 +1,5 @@ -using Avalonia.Media; +using System; +using Avalonia.Media; using Avalonia.Metadata; using Svg.Model; @@ -9,6 +10,11 @@ namespace Avalonia.Svg.Skia; /// public class SvgImage : AvaloniaObject, IImage { + /// + /// Raised when the resource changes visually. + /// + public event EventHandler? Invalidated; + /// /// Defines the property. /// @@ -99,6 +105,7 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang if (change.Property == SourceProperty) { // TODO: Invalidate IImage + RaiseInvalidated(EventArgs.Empty); } if (change.Property == CssProperty) @@ -108,6 +115,7 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang if (Source?.Css != css) { Source?.ReLoad(new SvgParameters(null, css)); + RaiseInvalidated(EventArgs.Empty); } } @@ -118,7 +126,14 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang if (Source?.Css != css) { Source?.ReLoad(new SvgParameters(null, css)); + RaiseInvalidated(EventArgs.Empty); } } } + + /// + /// Raises the event. + /// + /// The event args. + protected void RaiseInvalidated(EventArgs e) => Invalidated?.Invoke(this, e); }