diff --git a/ILSpy.BamlDecompiler/Rewrite/MarkupExtensionRewritePass.cs b/ILSpy.BamlDecompiler/Rewrite/MarkupExtensionRewritePass.cs index e2411672f..bd2bf8e31 100644 --- a/ILSpy.BamlDecompiler/Rewrite/MarkupExtensionRewritePass.cs +++ b/ILSpy.BamlDecompiler/Rewrite/MarkupExtensionRewritePass.cs @@ -77,14 +77,16 @@ namespace ILSpy.BamlDecompiler.Rewrite { var attrName = elem.Name; if (attrName != key) attrName = property.ToXName(ctx, parent, property.IsAttachedTo(type)); - var attr = new XAttribute(attrName, extValue); - var list = new List(parent.Attributes()); - if (attrName == key) - list.Insert(0, attr); - else - list.Add(attr); - parent.RemoveAttributes(); - parent.ReplaceAttributes(list); + if (!parent.Attributes(attrName).Any()) { + var attr = new XAttribute(attrName, extValue); + var list = new List(parent.Attributes()); + if (attrName == key) + list.Insert(0, attr); + else + list.Add(attr); + parent.RemoveAttributes(); + parent.ReplaceAttributes(list); + } elem.Remove(); return true;