title: UIElement to image file (WP7)
body: <p>I have a <code>StackPanel</code> which includes a few <code>Rectangles</code> that I want put to an image file (e.g. PNG). I'm developing this on Windows Phone 7 and most of the information I found on the internet wasn't applicable (I think) to WP7.</p>
  
  <p>I think the <code>System.Windows.Media.Imaging</code> namespace is the key to this, but I'm not sure where to begin.</p>
  
  <p><strong>This is basically what I want to do:</strong></p>
  
  <pre><code>StackPanel stack = new StackPanel();
  List&lt;Rectangle&gt; recList = new List&lt;Rectangle&gt;();
  </code></pre>
  
  <p>add some rectangles to <code>recList</code></p>
  
  <pre><code>foreach(var x in recList)
       stack.Children.Add(x);
  </code></pre>
  
  <p>then save the stackpanel to an image file...</p>