EthanHunt
EthanHunt

Reputation: 463

Take screenshot from WPF

Is it possible to take screenshot of the single element on WPF form? I need to take screenshot of a "border" tool and its child.

Upvotes: 4

Views: 1804

Answers (2)

Viv
Viv

Reputation: 2595

considering source to be the element that you want to take a screenshot. This is the code that I have which saves it to the clipboard.

        RenderTargetBitmap bmp = new RenderTargetBitmap((int)source.ActualWidth, (int)source.ActualHeight, 96, 96, PixelFormats.Pbgra32);
        bmp.Render(source);
        Clipboard.SetImage(bmp);

Upvotes: 2

brunnerh
brunnerh

Reputation: 184516

You can use RenderTargetBitmap to render visuals, if you search for it on SO there should be some questions that help if the reference is not enough.

Further this external article might help.

Upvotes: 1

Related Questions