ChartAfterRemdering event causes StackOverflowException

Questions or problems related to updating projects from v.6 to v.7

Moderator: Arction_LasseP

Posts: 24
Joined: Mon Sep 12, 2016 7:52 am

ChartAfterRemdering event causes StackOverflowException

Post by matus » Mon Sep 12, 2016 8:00 am

after updating to 7.1.4 from v6, we started to get System.StackOverflowException.
I suppose some propety setters are firing ChartAfterRemdering event in v7.

This is the handler:

Code: Select all

        private void ChartAfterRendering(object sender, AfterRenderingEventArgs args)
            if (_leftMargin == 0)

            _chart.ViewXY.AxisLayout.AutoAdjustMargins = false;
            var margin = _chart.ViewXY.Margins;
            margin.Left = _leftMargin + 30;
            _chart.ViewXY.Margins = margin;
Is there a list of actions, that cause firing of ChartAfterRemdering event?
How should this be handled?


Posts: 424
Joined: Mon Mar 14, 2016 9:22 am

Re: ChartAfterRemdering event causes StackOverflowException

Post by ArctionKestutis » Mon Sep 12, 2016 12:19 pm


AfterRendering event is called whenever refresh of rendering data happen: series data changed, axis range changed, properties set, mouseOver event etc.
In your example, two lines will cause firing:

Code: Select all

            _chart.ViewXY.AxisLayout.AutoAdjustMargins = false;
            _chart.ViewXY.Margins = margin;
To avoid infinite loop you can unsubscribe from event handler at the beginning of and again subscribe at the end. Other option for stopping infinite loop also available.
In this regard, maybe you don't need such strong event in your code. Please consider other events of the Chart or ViewXY.

Al the best,