path: root/Xamarin.Forms.ControlGallery.Windows
diff options
authorE.Z. Hart <>2017-04-25 18:16:25 (GMT)
committerRui Marinho <>2017-04-25 18:16:25 (GMT)
commitcdc405512844671bc3b2c8bd28f583036e5530a2 (patch)
tree881d68b4a26eecbbc77e76b86b3f322cd41b3e3d /Xamarin.Forms.ControlGallery.Windows
parent9631ec2d8bbac8b837955af238f322c1023af097 (diff)
Better error handling for image loading errors on iOS/Android (#849)
* First run at removing async void image update methods Consistent error logging and IsLoading on Android,iOS,UWP Move error logging into image handlers for better messages Add demo of custom ImageRenderer error handling Update docs Make the test smaller so the results don't get pushed offscreen Fix namespace error * Update error handling for fast image renderer * Update 37625 test to use image we control * Add java disposed check to avoid ObjectDisposedException in async operations * Add disposed checks to legacy renderer; null check element before SetIsLoading * Check disposed on GetDesiredSize for fast renderer Use local disposed member where possible for disposed check * Check for disposal after async handlers in iOS * Add disposal checks after async methods in Windows * Reset linker settings on project; reduce redundant casts in ImageViewExtensions
Diffstat (limited to 'Xamarin.Forms.ControlGallery.Windows')
1 files changed, 20 insertions, 1 deletions
diff --git a/Xamarin.Forms.ControlGallery.Windows/BrokenImageSourceHandler.cs b/Xamarin.Forms.ControlGallery.Windows/BrokenImageSourceHandler.cs
index ffe999e..42ee340 100644
--- a/Xamarin.Forms.ControlGallery.Windows/BrokenImageSourceHandler.cs
+++ b/Xamarin.Forms.ControlGallery.Windows/BrokenImageSourceHandler.cs
@@ -1,16 +1,20 @@
using System;
using System.Threading;
using System.Threading.Tasks;
+using Xamarin.Forms.Controls.Issues;
using WImageSource = Windows.UI.Xaml.Media.ImageSource;
using Xamarin.Forms.Platform.UWP;
+using Xamarin.Forms.ControlGallery.WindowsUniversal;
+[assembly: ExportRenderer(typeof(_51173Image), typeof(_51173CustomImageRenderer))]
namespace Xamarin.Forms.ControlGallery.WindowsUniversal
using Xamarin.Forms.Platform.WinRT;
+using Xamarin.Forms.ControlGallery.WinRT;
+[assembly: ExportRenderer(typeof(_51173Image), typeof(_51173CustomImageRenderer))]
namespace Xamarin.Forms.ControlGallery.WinRT
@@ -21,4 +25,19 @@ namespace Xamarin.Forms.ControlGallery.WinRT
throw new Exception("Fail");
+ public class _51173CustomImageRenderer : ImageRenderer
+ {
+ protected override async Task TryUpdateSource()
+ {
+ try
+ {
+ await UpdateSource().ConfigureAwait(false);
+ }
+ catch (Exception ex)
+ {
+ await Xamarin.Forms.Application.Current.MainPage.DisplayAlert("Image Error 51173", $"The image failed to load, here's why: {ex.Message}", "OK");
+ }
+ }
+ }
} \ No newline at end of file