New to Telerik UI for WPF? Download free 30-day trial

How to export the RadChartView without the pan and zoom scrollbars

Environment

Product RadChartView for WPF

Description

How to remove the pan and zoom scrollbars when exporting the RadChartView.

Solution

Set the PanMode and ZoomMode properties of the ChartPanAndZoomBehavior to None and make sure the chart is redrawn.

Example 1: Exporting the chart without scrollbars

var zoomModeCache = this.panZoomBehavior.ZoomMode; 
var panModeCache = this.panZoomBehavior.PanMode; 
this.panZoomBehavior.ZoomMode = ChartPanZoomMode.None; 
this.panZoomBehavior.PanMode = ChartPanZoomMode.None; 
 
// This forces the chart to be redrawn 
var size = this.chart.RenderSize; 
this.chart.Measure(Size.Empty); 
this.chart.Measure(size); 
this.chart.Arrange(new Rect(size)); 
this.chart.UpdateLayout(); 
 
string filename = "../../ExportedChart.png"; 
using (Stream fileStream = File.Open(filename, FileMode.OpenOrCreate)) 
{ 
    Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(this.chart, fileStream, new PngBitmapEncoder()); 
} 
 
this.panZoomBehavior.ZoomMode = zoomModeCache; 
this.panZoomBehavior.PanMode = panModeCache; 

See Also

In this article