Hi,
I have a small project that worked fine when referencing regular telerik dll.
Now I try to reference NoXaml dll, with the attached merged dictionary picture, the program fails on a NullReferenceException in Axis.CreateLabelTextBlock().
(Attached Call Stack)
After digging into it, I noticed that the exception occurs only when I write a style targetting telerik:LinearAxis local to my window.
Thanks for the help.
Benn.
4 Answers, 1 is accepted
Thank you for the provided information. I was able to reproduce the exception. This happens because the style probably is missing the BasedOn attribute. Because of this the default implicit style of the axis is overridden including its ControlTemplate. On the other hand the CreateLabelTextBlock() method depends on the elements in the template and the error gets thrown when they are not presented.
To resolve this you can base the custom LinearAxis Style to the default one of the control. Note that you should do this for any custom Style that targets Telerik control in a NoXaml scenario.
<
Window.Resources
>
<
Style
TargetType
=
"telerik:LinearAxis"
BasedOn
=
"{StaticResource AxisStyle}"
>
<
Setter
Property
=
"Opacity"
Value
=
"0.5"
/>
</
Style
>
</
Window.Resources
>
Regards,
Martin Ivanov
Progress Telerik
You are correct. Adding the BasedOn does solves the crash, but nothing is being shown on the chart.
Since the chart does not support series by binding (the number of curves changes by the loaded data), then it is being added by code, for example:
foreach (var curve in (DataContext as SamplingWindowModelBase).CurveLivingProperties)
{
LinearAxis verticalAxis = new LinearAxis();
verticalAxis.DataContext = curve;
verticalAxis.SmartLabelsMode = AxisSmartLabelsMode.SmartStep;
LineSeries curveLine = new LineSeries();
curveLine.DataContext = curve;
curveLine.VerticalAxis = verticalAxis;
chart1.Series.Add(curveLine);
}
When referencing the regular dlls, then I can see the series, but when referencing the NoXaml dlls and using the styles as shown on my first post (even when the LinearAxis I added is being commented), the chart shows "No data to plot".
Why?
In order to show the LineSeries you will also need to set its ItemsSource, CategoryBinding and ValueBinding properties. Check the Create Data-Bound Chart article to see how to do this in code-behind.
Additionally, the chart supports dynamic number of series create via custom models. You can read more about this in the Dynamic Number of Series article.
Regards,
Martin Ivanov
Progress Telerik
Hi,
Using the ChartSeriesProvider indeed solved the problem!
Thanks