Pre loader

AnimatedVisibleRange and TwoWay binding with other modifiers

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
1

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

  • You must to post comments
1
0

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

  • Andrew Burnett-Thompson
    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.
  • Andree Grosse
    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 to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies