I have a StackPanel which includes a few Rectangles 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.

I think the System.Windows.Media.Imaging namespace is the key to this, but I'm not sure where to begin.

This is basically what I want to do:

StackPanel stack = new StackPanel();
List<Rectangle> recList = new List<Rectangle>();

add some rectangles to recList

foreach(var x in recList)
     stack.Children.Add(x);

then save the stackpanel to an image file...

Edit
Report