summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/FileImageSource.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Core/FileImageSource.cs')
-rw-r--r--Xamarin.Forms.Core/FileImageSource.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/FileImageSource.cs b/Xamarin.Forms.Core/FileImageSource.cs
new file mode 100644
index 00000000..9e1d1e73
--- /dev/null
+++ b/Xamarin.Forms.Core/FileImageSource.cs
@@ -0,0 +1,38 @@
+using System.Threading.Tasks;
+
+namespace Xamarin.Forms
+{
+ [TypeConverter(typeof(FileImageSourceConverter))]
+ public sealed class FileImageSource : ImageSource
+ {
+ public static readonly BindableProperty FileProperty = BindableProperty.Create("File", typeof(string), typeof(FileImageSource), default(string));
+
+ public string File
+ {
+ get { return (string)GetValue(FileProperty); }
+ set { SetValue(FileProperty, value); }
+ }
+
+ public override Task<bool> Cancel()
+ {
+ return Task.FromResult(false);
+ }
+
+ public static implicit operator FileImageSource(string file)
+ {
+ return (FileImageSource)FromFile(file);
+ }
+
+ public static implicit operator string(FileImageSource file)
+ {
+ return file != null ? file.File : null;
+ }
+
+ protected override void OnPropertyChanged(string propertyName = null)
+ {
+ if (propertyName == FileProperty.PropertyName)
+ OnSourceChanged();
+ base.OnPropertyChanged(propertyName);
+ }
+ }
+} \ No newline at end of file