2

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;
David Bekham
  • 2,175
  • 3
  • 27
  • 56

1 Answers1

0

Try this:

WriteableBitmap image = new WriteableBitmap((int)this.ActualWidth, (int)this.ActualHeight);
image.Render(element, new MatrixTransform());
image.Invalidate();
return image;
Amit Bhatiya
  • 2,621
  • 1
  • 12
  • 20