diff options
Diffstat (limited to 'Xamarin.Forms.ControlGallery.iOS/BrokenImageSourceHandler.cs')
-rw-r--r-- | Xamarin.Forms.ControlGallery.iOS/BrokenImageSourceHandler.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Xamarin.Forms.ControlGallery.iOS/BrokenImageSourceHandler.cs b/Xamarin.Forms.ControlGallery.iOS/BrokenImageSourceHandler.cs new file mode 100644 index 00000000..5e58764b --- /dev/null +++ b/Xamarin.Forms.ControlGallery.iOS/BrokenImageSourceHandler.cs @@ -0,0 +1,36 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using UIKit; +using Xamarin.Forms; +using Xamarin.Forms.ControlGallery.iOS; +using Xamarin.Forms.Controls.Issues; +using Xamarin.Forms.Platform.iOS; + +[assembly: ExportRenderer(typeof(_51173Image), typeof(_51173CustomImageRenderer))] +namespace Xamarin.Forms.ControlGallery.iOS +{ + public sealed class BrokenImageSourceHandler : IImageSourceHandler + { + public Task<UIImage> LoadImageAsync(ImageSource imagesource, CancellationToken cancelationToken = new CancellationToken(), + float scale = 1) + { + throw new Exception("Fail"); + } + } + + public class _51173CustomImageRenderer : ImageRenderer + { + protected override async Task TrySetImage(Image previous = null) + { + try + { + await SetImage(previous).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"); + } + } + } +} |