From 3e2c99608bb6ba206df3b4b5fdd905741c44e3da Mon Sep 17 00:00:00 2001 From: jkuehner Date: Mon, 29 Jul 2013 18:36:09 +0200 Subject: [PATCH] XamlTypeResolverProvider GetNamespaceOfPrefix needs to look also on ParentObject to find the XMLNS, because, new XML Element are created for Example for Binding, wich are not yet in the XML Tree, when XamlTypeResolverProvider is used, but the ParentObject Property is set! With this Method you find the correct Namespace through the Tree --- .../Project/XamlTypeResolverProvider.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeResolverProvider.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeResolverProvider.cs index 30827e9494..5bdf7ae47d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeResolverProvider.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeResolverProvider.cs @@ -29,16 +29,32 @@ namespace ICSharpCode.WpfDesign.XamlDom XmlElement ContainingElement{ get { return containingObject.XmlElement; } } + + private string GetNamespaceOfPrefix(string prefix) + { + var ns = ContainingElement.GetNamespaceOfPrefix(prefix); + if (!string.IsNullOrEmpty(ns)) + return ns; + var obj = containingObject; + while (obj != null) + { + ns = obj.XmlElement.GetNamespaceOfPrefix(prefix); + if (!string.IsNullOrEmpty(ns)) + return ns; + obj = obj.ParentObject; + } + return null; + } public Type Resolve(string typeName) { string typeNamespaceUri; string typeLocalName; if (typeName.Contains(":")) { - typeNamespaceUri = ContainingElement.GetNamespaceOfPrefix(typeName.Substring(0, typeName.IndexOf(':'))); + typeNamespaceUri = GetNamespaceOfPrefix(typeName.Substring(0, typeName.IndexOf(':'))); typeLocalName = typeName.Substring(typeName.IndexOf(':') + 1); } else { - typeNamespaceUri = ContainingElement.GetNamespaceOfPrefix(""); + typeNamespaceUri = GetNamespaceOfPrefix(""); typeLocalName = typeName; } if (string.IsNullOrEmpty(typeNamespaceUri))