summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WP8/Converters/ImageConverter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.WP8/Converters/ImageConverter.cs')
-rw-r--r--Xamarin.Forms.Platform.WP8/Converters/ImageConverter.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WP8/Converters/ImageConverter.cs b/Xamarin.Forms.Platform.WP8/Converters/ImageConverter.cs
new file mode 100644
index 00000000..2e8bdef6
--- /dev/null
+++ b/Xamarin.Forms.Platform.WP8/Converters/ImageConverter.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Globalization;
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms.Platform.WinPhone
+{
+ public class ImageConverter : System.Windows.Data.IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ var source = (ImageSource)value;
+ IImageSourceHandler handler;
+
+ if (source != null && (handler = Registrar.Registered.GetHandler<IImageSourceHandler>(source.GetType())) != null)
+ {
+ Task<System.Windows.Media.ImageSource> task = handler.LoadImageAsync(source);
+ return new AsyncValue<System.Windows.Media.ImageSource>(task, null);
+ }
+
+ return null;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
+ }
+ }
+} \ No newline at end of file