Setting Axis VisibleRange in Code or MVVM
Posted by Admin - on 21 March 2014 11:20 AM

With an Axis with AutoRange.Once or AutoRange.Never, you may set the VisibleRange, either in code, in XAML or via a binding (MVVM). C#:

var axis = new NumericAxis() { VisibleRange = new DoubleRange(0, 10) };

  XAML (Set in XAML):

<s:NumericAxis VisibleRange="0, 10"/>

  XAML (Binding):

<!-- Assumes a ViewModel property called AxisVisibleRange -->
<!-- TwoWay Binding is required -->
<s:NumericAxis VisibleRange="{Binding AxisVisibleRange, Mode=TwoWay}"/>

Animating Axis VisibleRange in code or MVVM

As well as setting a VisibleRange (which triggers immediate update), you may animate a VisibleRange in code or XAML. To do so, please use the following code: C#:

var axis = new NumericAxis() { AnimatedVisibleRange = new DoubleRange(0, 10) };

// OR

var axis = new NumericAxis();
axis.AnimateVisibleRangeTo(new DoubleRange(0, 10), TimeSpan.FromMilliseconds(300));

  XAML (Set in XAML):

<!-- Animates with duration of 500ms -->
<s:NumericAxis AnimatedVisibleRange="0, 10"/>

  XAML (Binding):

<!-- Assumes a ViewModel property called AxisVisibleRange -->
<!-- TwoWay Binding is required. Animates with duration of 500ms -->
<s:NumericAxis AnimatedVisibleRange="{Binding AxisVisibleRange, Mode=TwoWay}"/>

 

See also

A note about DependencyProperty Precedence and Axis.VisibleRange

 

(2 vote(s))
Helpful
Not helpful

CONTACT US

Not sure where to start? Contact us, we are happy to help!


CONTACT US

SciChart Ltd, 16 Beaufort Court, Admirals Way, Docklands, London, E14 9XL. Email: Legal Company Number: 07430048, VAT Number: 101957725