title: Serialize a UserControl to xaml, but not its children?
body: <p>There were quite a few changes made to the XAML serialization stack in .NET 4.0.  One of the changes is that when you serialize a UserControl, not only do you get the control itself, but you also get all of its children.</p>
  
  <pre><code>var sb = new StringBuilder();
  var writer = XmlWriter.Create(sb, new XmlWriterSettings
  {
      Indent = true,
      ConformanceLevel = ConformanceLevel.Fragment,
      OmitXmlDeclaration = true
  });
  var mgr = new XamlDesignerSerializationManager(writer);
  mgr.XamlWriterMode = XamlWriterMode.Expression;
  System.Windows.Markup.XamlWriter.Save(this, mgr);
  return sb.ToString();
  </code></pre>
  
  <p>Instead of getting, for example,</p>
  
  <pre><code>&lt;MyUserControl 
      xmlns="clr-namespace:MyNamespace" 
      SomeProperty="Add ten thousand child controls" /&gt;
  </code></pre>
  
  <p>You now get</p>
  
  <pre><code>&lt;MyUserControl 
      xmlns="clr-namespace:MyNamespace" 
      SomeProperty="Add ten thousand child controls"&gt;
      &lt;StackPanel xmlns="http://microsoft.com/something/xaml/dude"&gt;
            &lt;TextBlock Text="Child Control ONE!"/&gt;
            &lt;TextBlock Text="Child Control TWO!"/&gt;
            &lt;TextBlock Text="Child Control THREE!"/&gt;
            &lt;!--WTMFH?--&gt;
        &lt;TextBlock Text="Child Control TEN FRIGGEN THOUSAND!"/&gt;
      &lt;/StackPanel&gt;
  &lt;/MyUserControl/&gt;
  </code></pre>
  
  <p>How can I revert this behavior back to the original method?</p>