I need to create an image control. Doing this way
public static BitmapFrame CreateControlFrame(FrameworkElement control) { var width = control.ActualWidth == 0 ? control.Width : control.ActualWidth; var height = control.ActualHeight == 0 ? control.Height : control.ActualHeight; var bmp = new RenderTargetBitmap((int)Math.Ceiling(width), (int)Math.Ceiling(height), 96, 96, PixelFormats.Pbgra32); bmp.Render(control); return BitmapFrame.Create(bmp); } but it only works if my control is on the form and it is visible. And I need to create an image of the control that is not on the form or it is hidden ( Visibility = Hidden/Collapsed )
Ideally, like this
var btn = new Button(); btn.Content = "qwe"; btn.Width = 100; btn.Height = 30; WpfControlRenderer.CreateControlScreenshot(btn, "ss.png"); Maybe someone knows how?
RenderTargetBitmapdo? - iRumba