diff options
author | E.Z. Hart <hartez@users.noreply.github.com> | 2016-08-02 14:54:57 -0600 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-08-02 13:54:57 -0700 |
commit | 34048b7bb4e8bf55c712ffd92303cf260c491c0e (patch) | |
tree | 19236fb4e72b8833c87e19fd15d0958b947764fc /Xamarin.Forms.Core/Image.cs | |
parent | 08e282350cb3f1c2345125682f14934111af2f9c (diff) | |
download | xamarin-forms-34048b7bb4e8bf55c712ffd92303cf260c491c0e.tar.gz xamarin-forms-34048b7bb4e8bf55c712ffd92303cf260c491c0e.tar.bz2 xamarin-forms-34048b7bb4e8bf55c712ffd92303cf260c491c0e.zip |
Change SourceChanged event on ImageSource to weak event to allow Images (#268)
referencing application-wide StaticResource ImageSources to be GCed
Diffstat (limited to 'Xamarin.Forms.Core/Image.cs')
-rw-r--r-- | Xamarin.Forms.Core/Image.cs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Xamarin.Forms.Core/Image.cs b/Xamarin.Forms.Core/Image.cs index 4292f952..dd2692ad 100644 --- a/Xamarin.Forms.Core/Image.cs +++ b/Xamarin.Forms.Core/Image.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Reflection; using Xamarin.Forms.Internals; using Xamarin.Forms.Platform; @@ -7,8 +9,8 @@ namespace Xamarin.Forms [RenderWith(typeof(_ImageRenderer))] public class Image : View, IImageController { - public static readonly BindableProperty SourceProperty = BindableProperty.Create("Source", typeof(ImageSource), typeof(Image), default(ImageSource), propertyChanging: OnSourcePropertyChanging, - propertyChanged: OnSourcePropertyChanged); + public static readonly BindableProperty SourceProperty = BindableProperty.Create("Source", typeof(ImageSource), typeof(Image), default(ImageSource), + propertyChanging: OnSourcePropertyChanging, propertyChanged: OnSourcePropertyChanged); public static readonly BindableProperty AspectProperty = BindableProperty.Create("Aspect", typeof(Aspect), typeof(Image), Aspect.AspectFit); @@ -126,6 +128,7 @@ namespace Xamarin.Forms newvalue.SourceChanged += OnSourceChanged; SetInheritedBindingContext(newvalue, BindingContext); } + InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); } @@ -138,7 +141,7 @@ namespace Xamarin.Forms { if (oldvalue == null) return; - + oldvalue.SourceChanged -= OnSourceChanged; try { |