SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components


We bind a view model’s AxisCollection to a surface’s XAxes. But our view model lives longer than the surface. It might get bound to a new surface as users click away (causing surface Dispose), then back to the chart (causing new Surface).

This used to work in SciChart 5.1, but broke when we upgrade to 5.5.

Seems to be because SciChartSurface now does UnsubscribeInnerCollection on that AxisCollection when the surface is disposed.
It means clear and re-add to that AxisCollection no longer automatically set IsPrimaryAxis = true on one axis. Which causes issues with various things that expect one (e.g. modifiers).

We can work around it (set IsPrimaryAxis true ourselves), but does this change mean you’re not expecting one AxisCollection to get re-used across different surface instances (but only one at a time)?


  • You must to post comments

Hi Michael

It’s for this reason that we created the AxisBinding API in SciChart WPF v5 or later, because binding to a AxisCollection resulted in problems like this.

AxisCollection is a list of AxisBase classes, which are FrameworkElements. In WPF, a FrameworkElement can only have one logical parent at a time. Binding a single AxisCollection to two SciChartSurfaces will result in unexpected behaviour (even if it is unintentional due to the way bindings work)

Take a look at the new AxisBinding Markup extension we introduced into SciChart. This lets you declare a collection of AxisViewmodels in your Chart ViewModel and then SciChart dynamically generates the Axis elements for you.

Best regards,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.