Problem with Rezising in code behind

2 posts, 0 answers
  1. Thomas
    Thomas avatar
    28 posts
    Member since:
    Jun 2010

    Posted 05 Jun 2012 Link to this post


    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,
  2. Rosko
    Rosko avatar
    137 posts

    Posted 08 Jun 2012 Link to this post

    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 >>

Back to Top