summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/ConstraintTypeConverter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Core/ConstraintTypeConverter.cs')
-rw-r--r--Xamarin.Forms.Core/ConstraintTypeConverter.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/ConstraintTypeConverter.cs b/Xamarin.Forms.Core/ConstraintTypeConverter.cs
new file mode 100644
index 00000000..8cc45229
--- /dev/null
+++ b/Xamarin.Forms.Core/ConstraintTypeConverter.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Globalization;
+
+namespace Xamarin.Forms
+{
+ public class ConstraintTypeConverter : TypeConverter
+ {
+ public override object ConvertFromInvariantString(string value)
+ {
+ double size;
+ if (value != null && double.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out size))
+ return Constraint.Constant(size);
+
+ throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", value, typeof(Color)));
+ }
+ }
+} \ No newline at end of file