How to control prefixes of namespaces in XML document generated by XmlWriter - generated XAML with x:Type markup extension

StackOverflow https://stackoverflow.com/questions/3250466

Question

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?

Was it helpful?

Solution

I've found that:

new XAttribute(XNamespace.Xmlns + "p", "http://schemas.microsoft.com/winfx/2006/xaml/presentation"); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top