From 001cf40835cf9f0001f957e64d10ee34f5cdafaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20S=CC=8Colte=CC=81s?= Date: Thu, 14 Mar 2024 23:48:40 +0100 Subject: [PATCH] Update SvgImage.cs --- src/Avalonia.Svg.Skia/SvgImage.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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); }