title: Creating a Silverlight DataTemplate in code
body: <p>How do I create a silverlight data template in code? I've seen plenty of examples for WPF, but nothing for Silverlight.</p>
  
  <p>Edit: Here's the code I'm now using this for, based on the answer from Santiago below.</p>
  
  <pre><code>public DataTemplate Create(Type type)
  {
    return (DataTemplate)XamlReader.Load(
            @"&lt;DataTemplate
              xmlns=""http://schemas.microsoft.com/client/2007""&gt;
              &lt;" + type.Name + @" Text=""{Binding " + ShowColumn + @"}""/&gt;
              &lt;/DataTemplate&gt;"
     );
  }
  </code></pre>
  
  <p>This works really nicely and allows me to change the binding on the fly. </p>