Browse Source

Fixes in Template helper:

Remove Added Key and Namespaces...
pull/604/head
jogibear9988 12 years ago
parent
commit
0922851312
  1. 19
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs

19
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs

@ -51,15 +51,21 @@ namespace ICSharpCode.WpfDesign.XamlDom
break; break;
} }
foreach (var dictentry in ns) foreach (var dictentry in ns.ToList())
{ {
if (xmlElement.HasAttribute("xmlns:" + dictentry.Key))
ns.Remove(dictentry.Key);
else
xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value); xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value);
} }
var keyAttrib = xmlElement.GetAttribute("Key", XamlConstants.XamlNamespace); var keyAttrib = xmlElement.GetAttribute("Key", XamlConstants.XamlNamespace);
if (string.IsNullOrEmpty(keyAttrib)) bool keySet = false;
if (string.IsNullOrEmpty(keyAttrib)) {
keySet = true;
xmlElement.SetAttribute("Key", XamlConstants.XamlNamespace, "$$temp&&§§%%__"); xmlElement.SetAttribute("Key", XamlConstants.XamlNamespace, "$$temp&&§§%%__");
}
var xaml = xmlElement.OuterXml; var xaml = xmlElement.OuterXml;
xaml = "<ResourceDictionary xmlns=\"http://schemas.microsoft.com/netfx/2007/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">" + xaml + "</ResourceDictionary>"; xaml = "<ResourceDictionary xmlns=\"http://schemas.microsoft.com/netfx/2007/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">" + xaml + "</ResourceDictionary>";
@ -111,11 +117,20 @@ namespace ICSharpCode.WpfDesign.XamlDom
var result = (ResourceDictionary)writer.Result; var result = (ResourceDictionary)writer.Result;
if (keySet)
xmlElement.RemoveAttribute("Key", XamlConstants.XamlNamespace);
foreach (var dictentry in ns)
{
xmlElement.RemoveAttribute("xmlns:" + dictentry.Key);
}
var enr = result.Keys.GetEnumerator(); var enr = result.Keys.GetEnumerator();
enr.MoveNext(); enr.MoveNext();
var rdKey = enr.Current; var rdKey = enr.Current;
var template = result[rdKey] as FrameworkTemplate; var template = result[rdKey] as FrameworkTemplate;
result.Remove(rdKey); result.Remove(rdKey);
return template; return template;
} }

Loading…
Cancel
Save