Browse Source

Xaml Object

When using GetPrefixOfNamespace the XMLElement may not yet be in the XML Tree, but the Xaml Object has it ParentObject Property already set, so use this!
pull/52/head
jkuehner 13 years ago
parent
commit
71897c0ffc
  1. 37
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs

37
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs

@ -97,7 +97,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -97,7 +97,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
XmlAttribute xmlAttribute;
internal XmlAttribute XmlAttribute {
internal XmlAttribute XmlAttribute {
get { return xmlAttribute; }
set {
xmlAttribute = value;
@ -105,9 +105,26 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -105,9 +105,26 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
static XmlElement VirtualAttachTo(XmlElement e, XmlElement target)
string GetPrefixOfNamespace(string ns, XmlElement target)
{
var prefix = target.GetPrefixOfNamespace(e.NamespaceURI);
var prefix = target.GetPrefixOfNamespace(ns);
if (!string.IsNullOrEmpty(prefix))
return prefix;
var obj = this;
while (obj != null)
{
prefix = obj.XmlElement.GetPrefixOfNamespace(ns);
if (!string.IsNullOrEmpty(prefix))
return prefix;
obj = obj.ParentObject;
}
return null;
}
XmlElement VirtualAttachTo(XmlElement e, XmlElement target)
{
var prefix = GetPrefixOfNamespace(e.NamespaceURI, target);
XmlElement newElement = e.OwnerDocument.CreateElement(prefix, e.LocalName, e.NamespaceURI);
foreach (XmlAttribute a in target.Attributes) {
@ -153,7 +170,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -153,7 +170,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
internal override void RemoveNodeFromParent()
{
{
if (XmlAttribute != null) {
XmlAttribute.OwnerElement.RemoveAttribute(XmlAttribute.Name);
xmlAttribute = null;
@ -162,7 +179,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -162,7 +179,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (!UpdateXmlAttribute(false, out holder)) {
element.ParentNode.RemoveChild(element);
}
}
}
//TODO: PropertyValue still there
//UpdateMarkupExtensionChain();
}
@ -174,7 +191,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -174,7 +191,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
XamlObject holder;
if (!UpdateXmlAttribute(false, out holder)) {
if (holder != null &&
holder.XmlAttribute != null) {
holder.XmlAttribute != null) {
holder.XmlAttribute.OwnerElement.RemoveAttributeNode(holder.XmlAttribute);
holder.xmlAttribute = null;
holder.ParentProperty.AddChildNodeToProperty(holder.element);
@ -201,7 +218,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -201,7 +218,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
while (obj != null && obj.IsMarkupExtension && obj.ParentProperty != null) {
obj.ParentProperty.UpdateValueOnInstance();
obj = obj.ParentObject;
}
}
}
bool UpdateXmlAttribute(bool force, out XamlObject holder)
@ -280,7 +297,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -280,7 +297,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// </summary>
public string ContentPropertyName {
get {
return contentPropertyName;
return contentPropertyName;
}
}
@ -293,7 +310,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -293,7 +310,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
throw new ArgumentNullException("propertyName");
// if (propertyName == ContentPropertyName)
// return
// return
foreach (XamlProperty p in properties) {
if (!p.IsAttached && p.PropertyName == propertyName)
@ -379,7 +396,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -379,7 +396,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
object ProvideValue()
{
{
if (wrapper != null) {
return wrapper.ProvideValue();
}

Loading…
Cancel
Save