From 92ec7d4e3f51709c447248b2436721ffa6049eea Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Sat, 11 Mar 2017 03:00:38 +0200 Subject: [PATCH] set wellknown extensions without completely replace original type --- .../PortableXaml/AvaloniaXamlSchemaContext.cs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Markup/Avalonia.Markup.Xaml/PortableXaml/AvaloniaXamlSchemaContext.cs b/src/Markup/Avalonia.Markup.Xaml/PortableXaml/AvaloniaXamlSchemaContext.cs index 1e7d78de72..6c0fb79558 100644 --- a/src/Markup/Avalonia.Markup.Xaml/PortableXaml/AvaloniaXamlSchemaContext.cs +++ b/src/Markup/Avalonia.Markup.Xaml/PortableXaml/AvaloniaXamlSchemaContext.cs @@ -72,6 +72,15 @@ namespace Avalonia.Markup.Xaml.PortableXaml xmlLocalName + "Extension", genArgs); + if (type != null) + { + Type extType; + if (_wellKnownExtensionTypes.TryGetValue(type, out extType)) + { + type = extType; + } + } + if (type == null) { //let's try the simple types @@ -160,19 +169,18 @@ namespace Avalonia.Markup.Xaml.PortableXaml private XamlType GetAvaloniaXamlType(Type type) { - Type extType; - - _wellKnownExtensionTypes.TryGetValue(type, out extType); + //if type is extension get the original type to check + var origType = _wellKnownExtensionTypes.FirstOrDefault(v => v.Value == type).Key; - if (typeof(IBinding).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) + if (typeof(IBinding).GetTypeInfo().IsAssignableFrom((origType ?? type).GetTypeInfo())) { - return new BindingXamlType(extType ?? type, this); + return new BindingXamlType(type, this); } - if (extType != null || + if (origType != null || typeof(AvaloniaObject).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) { - return new AvaloniaXamlType(extType ?? type, this); + return new AvaloniaXamlType(type, this); } return null;