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 Brian,
I just wanted to double-check, if I can assist you any further on this matter, and if not would you please verify the thread as answered so it helps other users with a similar predicament.
Thanks in advance.
Petar,
Your example works fine. Thanks a lot!
I was able to get it fixed using a workaround...
My charts have a Static ScatterSeries, along with all of their ScatterLineSeries, that just holds a duplicate of all of the points in the ScatterLineSeries, so that I can traverse the lines and whatnot.
For some reason, if the Visibility of that first series is set to Collapsed, none of the series are rendered, and the chart isn't re-measured, so I suspect there is something underlying that isn't checking all of those.
My workaround merely makes sure that all of the individual points are turned off, but that the series itself is still visible, then it renders the clipboard correctly
Thanks,
Brian
Hello all,
I have created a test sample () in C# following sykobag’s approach. along with saving the XamDataChart to file, with the difference that I did this on button clicks to avoid any rendering issues. Sykobag, I suppose that, as you mentioned, there might be something amiss in your project. If you could attach a test sample reproducing your scenario I’d be glad to look into it for you.
Please let me know if I could be of any further assistance.
Topical question!
Petar, could you give example how copy xamDataChart to clipboard in C#?