Copy Chart to Clipboard

Mar 31, 2011 at 2:13 PM

I'm trying to copy an image of a bar chart to clipboard so it can be pasted into another program (i.e. Powerpoint). The chart portion of the image copies ok, but the surrounding area that includes the axes, titles, and labels is solid black. I'm using the following code to try to grab a screen capture of the chart image.

private static BitmapSource CaptureScreen(Visual target, double dpiX, double dpiY)
            if (target == null)
                return null;
            Rect bounds = VisualTreeHelper.GetDescendantBounds(target);
            RenderTargetBitmap targetBitmap =
                 new RenderTargetBitmap((int)bounds.Width,
                           96d, 96d,
            BitmapSource source = BitmapFrame.Create(targetBitmap);
            return source;
Then I just do a Clipboard.SetImage() on the returned value. I'm assuming there is something obvious that I'm missing as pasting a screen capture isn't
that unusal of a goal. Any help or pointer to some sample code would be appreciated.