Hmm, this seems to be a WriteableBitmap behavior inherited from Silverlight. This link contains the explanation/answer:
http://forums.silverlight.net/t/115371.aspx/1
If the UI control being rendered is in the live visual tree, WriteableBitmap works. If not, you can try a workaround such as the one below (not tested):
public static WriteableBitmap WriteableBitmapFromUserControl(UserControl uc, int Width, int Height)
{
WriteableBitmap outputWriteableBitmap = null;
using (MemoryStream ms = new MemoryStream())
{
// Force UserControl to render to a certain size
// Based on post: http://forums.silverlight.net/forums/p/115371/413511.aspx
uc.Width = Width;
uc.Height = Height;
uc.Measure(new Size(Width, Height));
uc.Arrange(new Rect(0, 0, Width, Height));
// Write to Bitmpa and save to Memory Stream
outputWriteableBitmap = new WriteableBitmap(uc, null);
outputWriteableBitmap.SaveJpeg(ms, (int)uc.ActualWidth, (int)uc.ActualHeight, 0, 100);
// Cleanup
ms.Close();
}
return outputWriteableBitmap;
}Hope this helps,
Mark
Mark Chamberlain Sr. Escalation Engineer | Microsoft Developer Support | Windows Phone 7