diff --git a/src/Avalonia.Base/Media/Geometry.cs b/src/Avalonia.Base/Media/Geometry.cs
index 2019f54c70..b1fea53289 100644
--- a/src/Avalonia.Base/Media/Geometry.cs
+++ b/src/Avalonia.Base/Media/Geometry.cs
@@ -1,11 +1,14 @@
using System;
using Avalonia.Platform;
+using System.ComponentModel;
+using System.Globalization;
namespace Avalonia.Media
{
///
/// Defines a geometric shape.
- ///
+ ///
+ [TypeConverter(typeof(GeometryConverter))]
public abstract class Geometry : AvaloniaObject
{
///
@@ -199,4 +202,32 @@ namespace Avalonia.Media
return new CombinedGeometry(combineMode, geometry1, geometry2, transform);
}
}
+
+ public class GeometryConverter : TypeConverter
+ {
+ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
+ {
+ if (sourceType == typeof(string))
+ {
+ return true;
+ }
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
+ {
+ if (value is null)
+ {
+ throw GetConvertFromException(value);
+ }
+ string source = value as string;
+
+ if (source != null)
+ {
+ return Geometry.Parse(source);
+ }
+
+ return base.ConvertFrom(context, culture, value);
+ }
+ }
}