I am using WriteableBitmap in my WindowsPhone application to convert UIElement into WriteableBitmap. I am getting Value does not fall within the expected range exception randomly in the following code. But I am not able to find the root cause. Could you please anyone help me on this ?
Size imageSize = new Size(element.ActualWidth, element.ActualHeight);
WriteableBitmap image = new WriteableBitmap((int)imageSize.Width, (int)imageSize.Height);
image.Render(element, null);
image.Invalidate();
return image;