开发者

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.


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);


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜