I am using .NET 4.
I experience a strange behaviour with the object initializer combined with the ChartArea
.
The object initializer works with the Chart
class:
For example:
Chart ch = new Chart { Anchor = AnchorStyles.Bottom };
But it doesn't with the ChartArea:
ChartArea ca = new ChartArea { AxisX.Maximum = 1.0 };
The IntelliSense displays the AxisX
, but after implementing it says:
Cannot resolve symbol 'AxisX'
What happens here? Why it doesn't work? Is this a fault by me or by the compiler?
Thanks!
Try the below, shoudl work
ChartArea ca = new ChartArea { AxisX = new Axis {Maximum = 1.0 }};
Anchor is an enum, whereas AxisX is an object that represents the primary X-axis