Search code examples
c#wpfbitmapscreenshot

How do I convert a WPF window to a bitmap?


I want to take screen shots of all the windows associated with an application and allow the user to edit them. I am not sure how to convert a window to a bitmap image though.

I want to do something like this...

WindowCollection handles = Application.Current.Windows;
List<Image> windowList = new List<Image>();
foreach (Window window in handles)
{
do something here to turn each window into a bitmap
windowList.Add(bitmapFromWindow)
}

I have found related questions, but nothing that answers my question. If you find any related resources please post.


Solution

  • You can use RenderTargetBitmap

    or have a look at that one:

    http://blogs.msdn.com/b/swick/archive/2007/12/02/rendering-ink-and-image-to-a-bitmap-using-wpf.aspx