title: XamlReader - mapping multiple CLR namespaces to single XML namespace
body: <p>I have a WPF project with an <code>AssemblyInfo.cs</code> that groups multiple CLR namespaces into a single XML namespace:</p>
  
  <pre><code>[assembly: XmlnsDefinition("http://foo.bar", "MyLibary.Controls")]
  [assembly: XmlnsDefinition("http://foo.bar", "MyLibary.Converters")]
  </code></pre>
  
  <p>In XAML this is used like so:</p>
  
  <pre><code>&lt;UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:fb="http://foo.bar"&gt;
      &lt;fb:FooButton IsEnabled="{Binding Something, Converter={fb:FooConverter}}"/&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>This works great when the XAML is instantiated normally, but now I am now trying to dynamically load XAML files from my project using <code>XamlReader</code>.</p>
  
  <p>The problem: I can't seem to map multiple CLR namespaces to a single XML namespace. It seems that the last definition added to the <code>XamlTypeMapper</code> is the only one that persists (e.g. it clobbers previous registrations):</p>
  
  <pre><code>var parserContext = new ParserContext();
  parserContext.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");
  parserContext.XmlnsDictionary.Add("fb", "http://foo.bar");
  
  parserContext.XamlTypeMapper = new XamlTypeMapper(new string[] {"MyLibrary"});
  parserContext.XamlTypeMapper.AddMappingProcessingInstruction("http://foo.bar", "MyLibrary.Converters", "MyLibrary");
  parserContext.XamlTypeMapper.AddMappingProcessingInstruction("http://foo.bar", "MyLibrary.Controls", "MyLibrary");
  
  ...
  
  var rootNode = XamlReader.Load(memeoryStream, parserContext) as FrameworkElement
  </code></pre>
  
  <p>The error message is:</p>
  
  <pre><code>'Cannot create unknown type '{http://foo.bar}MyConverter'.'
  </code></pre>
  
  <p>If all put all my code under a single common CLR namespace, everything works but unfortunately this is not option. Has anybody mapped multiple CLR namespaces to a single XML namespace for the purpose of loading XAML content dynamically?</p>
  
  <p>Thanks in advance!</p>