I'm having problems adding CartesianGridLineAnnotations to my RadCartesianCharts. I've read the documentation on this page : http://www.telerik.com/help/wpf/radchartview-annotations-gridline.html and followed the example answer given in this forum post : http://www.telerik.com/forums/cartesian-chart-without-adding-new-axis-for-custom-line but whenever I try to add the annotation I get an error.
In the forum post you give the following example:
[code]
<telerik:RadCartesianChart x:Name="chart">
<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis />
</telerik:RadCartesianChart.VerticalAxis>
<telerik:RadCartesianChart.Annotations>
<telerik:CartesianGridLineAnnotation Axis="{Binding ElementName=chart, Path=VerticalAxis}" Value="25" />
[/code]
Which sets up the chart and axis, then adds the CartesianGridLineAnnotation, binding the Axis value to ther VerticalAxis in the element named "chart."
My code is as follows:
[code]
<telerik:RadCartesianChart x:Name="SummaryChart" UseLayoutRounding="True" Grid.Row="1" TooltipTemplate="{Template}">
<telerik:RadCartesianChart.HorizontalAxis>
<telerik:CategoricalAxis LabelFitMode="Rotate" />
</telerik:RadCartesianChart.HorizontalAxis>
<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis />
</telerik:RadCartesianChart.VerticalAxis>
<telerik:RadCartesianChart.Annotations>
<telerik:CartesianGridLineAnnotation Axis="{Binding ElementName=SummaryChart, Path=VerticalAxis}" Value="6" Stroke="Red" StrokeThickness="1"/>
</telerik:RadCartesianChart.Annotations>
[/code]
As far as I can tell this is following your example of how to bind to the Vertical axis.
However when I use this XAML I get the following binding error:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=SummaryChart'. BindingExpression:Path=VerticalAxis; DataItem=null; target element is 'CartesianGridLineAnnotation' (Name=''); target property is 'Axis' (type 'CartesianAxis')
Do you know what I'm doing wrong?
Thanks,
Andy.
In the forum post you give the following example:
[code]
<telerik:RadCartesianChart x:Name="chart">
<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis />
</telerik:RadCartesianChart.VerticalAxis>
<telerik:RadCartesianChart.Annotations>
<telerik:CartesianGridLineAnnotation Axis="{Binding ElementName=chart, Path=VerticalAxis}" Value="25" />
[/code]
Which sets up the chart and axis, then adds the CartesianGridLineAnnotation, binding the Axis value to ther VerticalAxis in the element named "chart."
My code is as follows:
[code]
<telerik:RadCartesianChart x:Name="SummaryChart" UseLayoutRounding="True" Grid.Row="1" TooltipTemplate="{Template}">
<telerik:RadCartesianChart.HorizontalAxis>
<telerik:CategoricalAxis LabelFitMode="Rotate" />
</telerik:RadCartesianChart.HorizontalAxis>
<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis />
</telerik:RadCartesianChart.VerticalAxis>
<telerik:RadCartesianChart.Annotations>
<telerik:CartesianGridLineAnnotation Axis="{Binding ElementName=SummaryChart, Path=VerticalAxis}" Value="6" Stroke="Red" StrokeThickness="1"/>
</telerik:RadCartesianChart.Annotations>
[/code]
As far as I can tell this is following your example of how to bind to the Vertical axis.
However when I use this XAML I get the following binding error:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=SummaryChart'. BindingExpression:Path=VerticalAxis; DataItem=null; target element is 'CartesianGridLineAnnotation' (Name=''); target property is 'Axis' (type 'CartesianAxis')
Do you know what I'm doing wrong?
Thanks,
Andy.