3

I am trying to generate XAML from XElements.

<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>

However, I have problem with x:Type markup extension. It is unable to resolve the prefix p:, because I do not know how to force output XAML to map prefix p to namespace http://schemas.microsoft.com/winfx/2006/xaml/presentation.

Is there a way to control how prefixes of XML namespaces will be generated? Or is it possible to force x:Type markup extension to take XML namespace name instead of prefix?

TN.
  • 18,874
  • 30
  • 99
  • 157

1 Answers1

1

I've found that:

new XAttribute(XNamespace.Xmlns + "p", "http://schemas.microsoft.com/winfx/2006/xaml/presentation"); 
TN.
  • 18,874
  • 30
  • 99
  • 157