.net 如何控制XmlWriter生成的带有x:Type标记扩展名的XAML生成的XML文档中名称空间的前缀

.net 如何控制XmlWriter生成的带有x:Type标记扩展名的XAML生成的XML文档中名称空间的前缀,.net,xml,xaml,xmlwriter,xamlreader,.net,Xml,Xaml,Xmlwriter,Xamlreader,我正在尝试从XElements生成XAML <Style xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <Style.BasedOn> <StaticResource> <StaticResource.ResourceKey> <Type xmlns="http://schemas.microsoft.com/wi

我正在尝试从XElements生成XAML

<Style xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
  <Style.BasedOn>
    <StaticResource> 
      <StaticResource.ResourceKey>
        <Type xmlns="http://schemas.microsoft.com/winfx/2006/xaml">
          <Type.TypeName>p:Window</Type.TypeName> 
        </Type>
      </StaticResource.ResourceKey>
    </StaticResource>
  </Style.BasedOn>
  ...
</Style>

p:窗户
...
但是,我对
x:Type
标记扩展有问题。它无法解析前缀
p:
,因为我不知道如何强制输出XAML将前缀
p
映射到命名空间
http://schemas.microsoft.com/winfx/2006/xaml/presentation

有没有一种方法可以控制如何生成XML名称空间的前缀?或者可以强制
x:Type
标记扩展采用XML名称空间名称而不是前缀吗?

我发现:

new XAttribute(XNamespace.Xmlns + "p", "http://schemas.microsoft.com/winfx/2006/xaml/presentation"); 

你把这个属性放在哪里?