private static void SourceChanged(AvaloniaPropertyChangedEventArgs e) { var image = e.Sender as Image; if (image == null) { return; } var instance = GetInstance(image); instance?.Dispose(); var value = e.NewValue; if (value is string s) { value = new Uri(s); } instance = new GifInstance { TargetControl = image }; instance.SetSource(value); SetInstance(image, instance); }
public static void SetInstance(Image target, GifInstance value) { target.SetValue(InstanceProperty, value); }