SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
Hi,
in a MVVM scenario, I bind the AnimatedVisibleRange to a property in the view model.
<s:SciChartSurface SeriesSource="{Binding ChartSeries}">
<s:SciChartSurface.XAxis>
<s:NumericAxis AxisTitle="x" AnimatedVisibleRange="{Binding XVisibleRange, Mode=TwoWay}" AutoRange="Never" />
</s:SciChartSurface.XAxis>
<s:SciChartSurface.YAxis>
<s:NumericAxis AxisTitle="y" AnimatedVisibleRange="{Binding YVisibleRange, Mode=TwoWay}" AutoRange="Never" />
</s:SciChartSurface.YAxis>
<s:SciChartSurface.ChartModifier>
<s:ModifierGroup>
<s:MouseWheelZoomModifier IsEnabled="True" XyDirection="XDirection"/>
</s:ModifierGroup>
</s:SciChartSurface.ChartModifier>
</s:SciChartSurface>
Setting the XVisibleRange property in the view model smoothly animates the view. However, when I zoom in the chart with the mouse wheel, the view model property receives no updates (so the XVisibleRange property in the view model always stays on the value initially set by the view model).
The same thing works when I bind he VisibleRange instead of the AnimatedVisibleRange, i.e. in that case I get an update of the view model property on every mouse wheel zoom.
Is this intendend, or a bug? Building a workaround would require additional bindings, which I would like to avoid.
Best regards,
Andree
Hi Andree,
Thanks for your inquiry. Concerning your question, it isn’t a bug. You don’t receive any updates in the ViewModel because the AnimatedVisibleRange property is not used for interaction. In fact, it is never set internally, because it has been designed to be used on user’s side in MVVM scenarios.
It is quite easy to workaround, but I would suggest changing approach and binding the whole axis instance instead. Then you could subscribe to the VisibleRangeChanged event to receive notifications and set VisibleRange calling IAxis.AnimateVisibleRangeTo(..).
Actually, this is what AnimatedVisibleRange does in property callback.
Hope this helps!
Best regards,
Yuriy
Please login first to submit.