TL/DR: What's the easiest method to change the namespace value using LINQ to XML, say from xmlns:gcs="clr-namespace:NsOne;assembly=AsmOne" to xmlns:gcs="clr-namespace:NsTwo;assembly=AsmTwo"?
Why? because:
I serialized Xaml using System.Windows.Markup.XamlWriter.Save(myControl). I want to visualize this GUI appearance somewhere else (deserializing using System.Windows.Markup.XamlReader.Parse(raw)), in another project.
I don't want to link to the original assembly!
I just need to change the namespace, so XamlReader.Parse(raw) won't throw an exception. I currently do it using regular-expressions and it works, but I don't like that method (e.g. if I have xmlns:gcs="clr-namespace:NsOne;assembly=AsmOne" inside a CDATA)
This is my serialized Xaml:
<FlowDocument PagePadding="5,0,5,0" AllowDrop="True"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:gcs="clr-namespace:NsOne;assembly=AsmOne"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<gcs:MyParagraph Margin="0,0,0,0">
<gcs:MyParagraph.MetaData>
<gcs:ParagraphMetaData UpdaterParagraphUniqueId="1" />
</gcs:MyParagraph.MetaData>
<Span>some text...</Span>
</gcs:MyParagraph>
<gcs:MyParagraph Margin="0,0,0,0" Background="#FFF0F0F0">
<gcs:MyParagraph.MetaData>
<gcs:ParagraphMetaData UpdaterParagraphUniqueId="2" />
</gcs:MyParagraph.MetaData>
<Span Foreground="#FF0000FF">some more text...</Span>
</gcs:MyParagraph>
</FlowDocument>
(MyParagraph and ParagraphMetaData are custom types and they both exist at the source assembly and the destination assembly. MyParagraph inherits WPF's Paragraph)