title: Compile/Execute XAML during program runtime
body: <p>I would like to create an WPF Application which retrieves XAML Code from a Database and displays the retrieved code.</p>
  
  <p>Lets say the database return the following code:</p>
  
  <pre><code>&lt;Window x:Class="WpfApplication1.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Grid x:Name="mainGrid"&gt;
          &lt;Button Content="test case 1" 
                  HorizontalAlignment="Left" 
                  Margin="10,10,0,0" 
                  VerticalAlignment="Top" 
                  Width="100" 
                  Click="TestCase1_OnClick" 
                  Height="29"/&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>How do i execute this code (or maybe just the content of the mainGrid) during runtime? </p>