I already was using Windows form chart and I was able to save the chart control in the clipboard with these codes:
Dim stream As New System.IO.MemoryStream()
SummaryChart.SaveImage(stream, System.Drawing.Imaging.ImageFormat.Bmp)
Dim bmp As New System.Drawing.Bitmap(stream)
Clipboard.SetDataObject(bmp)
But since the requirements have changed then I had to create the chart in the view with the use of WPF Chart toolkit :
xmlns:dv="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
SummaryChart.SaveImage does not work anymore. What is the best way of doing what I was doing before?
I have read this article: Get a bitmap image from a Control view and tried these codes:
Dim rtb = New RenderTargetBitmap(CInt(SummariesChart.ActualWidth),
CInt(SummariesChart.ActualHeight), 96, 96, PixelFormats.Pbgra32)
rtb.Render(SummariesChart)
Dim png = New PngBitmapEncoder()
png.Frames.Add(BitmapFrame.Create(rtb))
Dim stream = New MemoryStream()
png.Save(stream)
Clipboard.SetImage(rtb)
But still, it doesn't work. Can anybody help me?
Thanks.