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
- Andree Grosse asked 9 years ago
- last edited 9 years ago
- You must login to post comments
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
- Guest answered 9 years ago
-
To add to this, AnimatedVisibleRange is designed to allow a OneWay binding from ViewModel to Axis, allowing you to trigger animation to a visible range from a viewmodel. The VisibleRange property though allows TwoWay binding to a viewmodel. What Yuriy says is the best way, direct control over the axis can be achieved through the IAxis interface.
-
Ok, thanks for the quick answer Yuriy & Andrew! Using AnimateVisibleRangeTo(...) was one of the workaround I tried, and I can understand that it is a design decision to not set the AnimatedVisibleRange internally.
- You must login to post comments
Please login first to submit.