diff --git a/WpfDesign.XamlDom/Project/XamlProperty.cs b/WpfDesign.XamlDom/Project/XamlProperty.cs index 5f228de..5aff352 100644 --- a/WpfDesign.XamlDom/Project/XamlProperty.cs +++ b/WpfDesign.XamlDom/Project/XamlProperty.cs @@ -533,12 +533,13 @@ namespace ICSharpCode.WpfDesign.XamlDom string ns = ParentObject.OwnerDocument.GetNamespaceFor(PropertyTargetType); string prefix = element.GetPrefixOfNamespace(ns); - + if (String.IsNullOrEmpty(prefix)) { prefix = ParentObject.OwnerDocument.GetPrefixForNamespace(ns); } - - if (!string.IsNullOrEmpty(prefix)) { + var existingNameSpace = element.GetNamespaceOfPrefix(prefix); + + if (!string.IsNullOrEmpty(prefix) || existingNameSpace != ns) { element.SetAttribute(name, ns, value); return element.GetAttributeNode(name, ns); }