I have an element Framedisplaying an html page in my WPF application and would like to save a screenshot of the frame as an image.
Using 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 webpage as an image in my application?
source
share