3

我正在尝试从 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>

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

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

4

1 回答 1

1

我发现:

new XAttribute(XNamespace.Xmlns + "p", "http://schemas.microsoft.com/winfx/2006/xaml/presentation"); 
于 2010-09-08T18:42:36.587 回答