I have a set of controls inside a WindowsFormsHost
and I would like to capture the current view and just save it as an image, I however only get some Panel
visible in the Image.
Is it possible to use the WindowsFormsHost as a "Visual" and capture the wrapped controls?
See my example:
<WindowsFormsHost x:Name="windowHost">
<wf:Panel Dock="Fill" x:Name="basePanel"/>
</WindowsFormsHost>
If i were to add a Button or whatever to the basePanel
this wouldn't be visible when exporting to a PNG with the following code:
RenderTargetBitmap rtb = new RenderTargetBitmap(basePanel.Width,
basePanel.Height, 96, 96, PixelFormats.Pbgra32);
rtb.Render(windowHost);
PngBitmapEncoder pnge = new PngBitmapEncoder();
pnge.Frames.Add(BitmapFrame.Create(rtb));
Stream stream = File.Create("test.jpg");
pnge.Save(stream);
stream.Close();
Suggestions on why this might not work and maybe a possible work-around? I guess it's not really suppose to work this way, but one could really hope!