I have a Frame
element displaying an html page in my WPF application, and would like to save a screenshot of the Frame as an image.
With the help of the google, I have this code:
Size size = new Size(PreviewFrame.ActualWidth, PreviewFrame.ActualHeight);
PreviewFrame.Measure(size);
PreviewFrame.Arrange(new Rect(size));
var renderBitmap = new RenderTargetBitmap(
(int)size.Width,
(int)size.Height,
96d,
96d,
PixelFormats.Pbgra32);
renderBitmap.Render(PreviewFrame);
But all I ever get is a blank image.
Any thoughts on how to fix this code, and/or another way to capture a web page as an image in my app?