I am trying to copy a XamDataChart to my clipboard, this is what i am currently using:
Dim OldSize As New Size(Me.ActualWidth, Me.ActualHeight) copyChart.Measure(New Size(Me.ActualWidth, Me.ActualHeight)) copyChart.Arrange(New Rect(0, 0, Me.ActualWidth, Me.ActualHeight)) Dim Tb As New RenderTargetBitmap(CInt(Me.ActualWidth), CInt(Me.ActualHeight), 96, 96, PixelFormats.Pbgra32) copyChart.UpdateLayout() Tb.Render(copyChart) Clipboard.SetImage(Tb)
Dim OldSize As New Size(Me.ActualWidth, Me.ActualHeight) copyChart.Measure(New Size(Me.ActualWidth, Me.ActualHeight)) copyChart.Arrange(New Rect(0, 0, Me.ActualWidth, Me.ActualHeight))
Dim Tb As New RenderTargetBitmap(CInt(Me.ActualWidth), CInt(Me.ActualHeight), 96, 96, PixelFormats.Pbgra32) copyChart.UpdateLayout() Tb.Render(copyChart) Clipboard.SetImage(Tb)
This creates the chart and copies it to the clipboard, but the lines aren't on there, and it's not drawn quite correctly...is there a quick snippet that will copy a chart to clipboard?
Hi,
I tried this sample and everything worked except one thing. When I copy to clipboard and then paste into for example paint or word, I get a black border on the top and left sides. This border is not there when you export to a png file.
Is it possible to get rid of this border?
Kind Regards
Fredrik Dahlberg
Hi Brian,
Yes, I tested it by adding another series to my sample. I am attaching the modified version for your reference (DataChart_to_Image_modified.zip).
Hope this helps you find the real issue.
I have the latest service release already.
When you tested this behavior was it using your sample? I'm afraid my application is much larger than a sample, and there could be an issue with it somewhere else.
But, if your copy to clipboard works with the first series visibility turned off, then it must be something else in my code somewhere, which unfortunately i don't have the time to find right now...so I won't need anything else from you.
Thanks,
Brian
Hello Brian,
I tried to reproduce this behavior with the latest Service Release and all other Series are visible after I hide the first one (Visibility="Hidden" / Visibility="Collapsed"). Please download and install the latest Service Release and let me know if you can still reproduce this issue.
Looking forward to hearing from you.
Petar,
As I said in my previous post, I have a workaround that makes it work for my special case.
However, I think there may be something inherently wrong with the code that causes it to not render properly if the first series is not visible.