Currently, the control relies on its IsLoaded property to determine if it should render its items (axes, data points, annotations, etc.). However, if you measure and arrange the control in code without adding it into the visual tree, the IsLoaded property is not set to True, therefore the chart is not rendered and the image gets empty.
Title: RadCartesianChart incorrecly rendered
We're rendering (Telerik) charts in code behind, to include them in a dynamic documentation.
For most controls it works fine - using standard methods (rendering control with System.Windows.Media.Imaging.RenderTargetBitmap and saving the result BitmapSource to disk)
However, it's impossible with RadCartesianChart with CategoricalSeriesDescriptor or ChartSeriesDescriptor. What we are able to get are axes and descriptions, but not bars.
I'm attaching an example - MainWindow displays a chart. I try to also create the chart in code behind.
In CreateAndSaveChart() method I create a chart with a DataContext, then I call Measure and Arrange methods on it. At this stage the control should be properly initialized and ready to render. (For simplicity I omit rendering control with RenderTargetBitmap - you can preview the control with WPF Tree Visualizer, which will give you the same result). Well, if you preview the control at this stage, you'll see that the chart is missing bars.
Next I create a new Window with my chart as a content, and display it for a while. Now the chart is fully and correctly rendered. As a workaround we display some Telerik chart in a transparent window to fully render, but such a workaround was reported not to work for some clients and is unacceptable in a long run. With most of Telerik charts we don't have such problems.
- for other Telerik charts we need to wait a few seconds to have it fully rendered. It's be better to have an event informing that the control is ready.
I'll be happy to add more details if you need any.
* While experimenting with the example I've suddenly managed to render the chart with bars, but this time the rendered size was incorrect (very small)