This is a migrated thread and some comments may be shown as answers.

Problem with Rezising in code behind

1 Answer 67 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Thomas asked on 05 Jun 2012, 02:06 PM

i use a print method in my program to print every usercontrol the user want to. this method transforms the usercontrols to the printer-size before the real printing starts.
it seems that the radchart has a problem with rezising. you can see the problem in the attachment.
Everything resizes correctly, exept the ChartArea (ChartArea starts at 2k instead of 0). I've tried to call UpdateLayout or Invalidate... on the Chart and/or ChartArea, but nothing seems to work.
Could anyone please help me?

Best Regards,

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 08 Jun 2012, 07:21 AM
Hello Thomas,

You are on the right way of solving this. When you set the height and width, the layout system of WPF is not invoked to do the necessary things to update the layout of the UI control. So, you need to do that manually. You can see in the code snippet what it is need to be done basically in the click event. In case you are interested in how the layout system of WPF works, you see this online reading.

private void ExportClick(object sender, RoutedEventArgs e)
            radChart.DefaultView.ChartArea.EnableAnimations = false;
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.DefaultExt = "png";
            if (!(bool)dialog.ShowDialog())
            Stream fileStream = dialog.OpenFile();
            radChart.Height = double.Parse(textBox1.Text);
            radChart.Width = double.Parse(textBox2.Text);
            radChart.Measure(new Size(radChart.Width, radChart.Height));
            radChart.Arrange(new Rect(radChart.DesiredSize));

the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question