Print Charts

Jan 27, 2015 at 4:39 PM

Is there any easy way to print the charts?
Tried to use RenderTargetBitmap to render the chart control in a ContentControl (or ViewBox),
but I only get the control with the title not the content (bars) in the image.

Here's some code:
var columnChart = new ClusteredColumnChart();
columnChart.ChartTitle = "My Title";
columnChart.Width = 600;
columnChart.Height = 400;

var columnChartSeries = new ChartSeries();
columnChartSeries.SeriesTitle = "My Series Title";
columnChartSeries.DisplayMember = "Column1";
columnChartSeries.ValueMember = "Column2";
columnChartSeries.ItemsSource = chartData;

var contentControl = new ContentControl();
contentControl.Content = columnChart;
contentControl.Measure(new System.Windows.Size(Double.PositiveInfinity, Double.PositiveInfinity));
contentControl.Arrange(new Rect(contentControl.DesiredSize));

var render = new RenderTargetBitmap(600, 400, 96, 96, PixelFormats.Pbgra32);
same code works fine to show the chart in a WPF window.

Thanks for any help
Jun 8, 2015 at 11:10 AM
Use the PrintDialog function from WPF itself.