Browse Source

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
pull/52/head
jkuehner 13 years ago
parent
commit
3e2c99608b
  1. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeResolverProvider.cs

20
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeResolverProvider.cs

@ -29,16 +29,32 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -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))

Loading…
Cancel
Save