Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
55
XamDataChart does not render LineSeries properly for export to image or PDF without first displaying on screen
posted

I've tried everything. I've found a blog post such as this one: 

http://www.infragistics.com/community/blogs/petar_monov/archive/2013/02/25/controls-to-images-behind-the-scene.aspx

I've looked at other support tickets such as these:

http://www.infragistics.com/community/forums/t/76885.aspx

http://www.infragistics.com/community/forums/t/3358.aspx

It appears that no matter what I try, I can't get the XamDataChart to draw the lines that represent a series of data unless I first display the chart on the screen and the UI dispatcher thread suspends and user input is again active.

I am trying to export several XamDataChart controls to a PDF file using a third party PDF conversion library, but I've created a simple project to demonstrate my issue. This project displays two charts in one window. Then in code behind it creates another set of charts and copies a bitmap representation of them to the clipboard. The image will show the charts, but none of the traces show up. (Even after performing Measure(), Arrange(), UpdateLayout()) If I add the chart to the visual tree by adding them to a window that I display, and then re-render them, magically, all the lines show up again.

What is going on here? Am I doing something wrong? Why are the LineSeries that are created not shown until the charts are displayed on screen?

(Please note, this code was just thrown together and I realize that there is a bug with the X-Axis not displaying, that is not the issue I am concerned with)

The test program flows like this:

1. The main window is displayed with the first chart using lots of data binding. The second chart has it's lines defined and attached in code behind.

first window

2. The user clicks the first button to render another instance of the control that contains the two charts in code behind (this simulates what I want to do to export the charts to a PDF). After the button is clicked, the control is rendered as a bitmap image and copied to the clipboard. (I created and saved the image in a photo editor)

first render

3. The user clicks the second button. A new window is created and its content is set to be the control that was previously created in code-behind. The control is now displayed properly. 

second window

4. In step 3 a new image was rendered based off of the same control that was created in code behind. This rendered image is again copied to the clipboard. It magically shows the Lines that were created before now...

second render

XamDataChartBug.zip