I'm serializing a object via XamlWriter.Save(object). This works as expected.
Problem now is, XamlWriter sets the namespaces as it needs, for example the root Namespace xmlns is set to the namespace of my object.
Problem is, I want to copy the xaml into a existing one, where already namespaces are defined. It works, because the XamlWriter also adds the namespace attributes to the generated string, but I want that my already existing prefixes will be reused. Is this possible?
Sample XAML:
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:assembly="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:shared="urn:mlog-sharedclasses-ns"
xmlns:visu="urn:mlog-visucommon-ns"
Width="2000"
Height="1000"
Background="White"
TextBlock.FontFamily="{StaticResource OpenSans}"
assembly:Name="rootElement"
mc:Ignorable="d">
<Grid.Resources>
<BoolToBrushConverter xmlns="clr-namespace:ControlPanel.SharedClasses.Converters;assembly=MCC.ControlPanel.SharedClasses"
FalseValue="#FF00FFFF"
TrueValue="#FF0000FF"
assembly:Key="ID_880cf_BorderBrush_Converter" />
</Grid.Resources>
<visu:TagRootCanvas>
<Button Content="Button"
Width="412"
Height="231"
Canvas.Left="33"
Canvas.Top="71"
assembly:Name="ID_880cf">
<i:Interaction.Behaviors>
<visu:TagBindingBehavior xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns="urn:mlog-visucommon-ns"
Converter="{av:StaticResource ID_880cf_BorderBrush_Converter}"
Debug="False"
Mode="OneWay"
Property="{shared:Static Member=av:Border.BorderBrushProperty}"
TagDataType="Bool"
TagName="aaa"
UpdateSourceTrigger="Default"
UseConvertedNullAsFallback="False" />
</i:Interaction.Behaviors>
</Button>
</visu:TagRootCanvas>
</Grid>
I create the TagBindingBehavior later via XamlWriter.Save and add it to my document. But it has different Namespaces. I want to remove the "xmlns" attributes from TagBindingBehavior.