Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
110
Finer precision on XamNumericRangeSlider
posted

I'm creating a XamNumericRangeSlider in code behind.

I'm then adding a min SliderTickMarks, and max SliderTickMarks.

I'm then adding a min XamSliderNumericThumb, and max XamSliderNumericThumb.

When displayed I move the min and max thumbs, and I don't get the precision I'm looking for.

Originally I set the min thumb at 0.0, and max thumb at 10.0. I move the thumbs, and the thumb increments are random. I move the max thumb a bit, the value changes to 10.36, and further move it, and value changes to 10.73. 

I would like the increments to be in 0.01. How can I achieve this please.

Here is my code...

  // Create xam range slider

      XamNumericRangeSlider rangeSlider = new XamNumericRangeSlider();

      rangeSlider.Name = "nrsSlider";

      rangeSlider.ThumbValueChanged += new EventHandler<ThumbValueChangedEventArgs<double>>(rangeSlider_ThumbValueChanged);

      rangeSlider.IsSelectionRangeEnabled = true;

      rangeSlider.TrackClickAction = SliderTrackClickAction.MoveToPoint;

      rangeSlider.IsMouseWheelEnabled = true;

      rangeSlider.MinValue = 0.0;

      rangeSlider.FontSize = 8;

      rangeSlider.MaxValue = 100.0;

      rangeSlider.Margin = new Thickness(5, 5, 5, 5);

      rangeSlider.IncreaseButtonVisibility = System.Windows.Visibility.Collapsed;

      rangeSlider.DecreaseButtonVisibility = System.Windows.Visibility.Collapsed;

 

      // Create min tick mark for slider

      SliderTickMarks minTickMark = new SliderTickMarks();

      minTickMark.TickMarksFrequency = 5.0;

      minTickMark.IncludeSliderEnds = true;

      minTickMark.UseFrequency = true;

      rangeSlider.TickMarks.Add(minTickMark);

 

      // Create max tick mark for slider

      SliderTickMarks maxTickMark = new SliderTickMarks();

      maxTickMark.TickMarksFrequency = 10.0;

      maxTickMark.IncludeSliderEnds = true;

      maxTickMark.UseFrequency = true;

      DataTemplate maxTickDisplay = (DataTemplate)FindResource("HorizontalTick");

      maxTickMark.HorizontalTickMarksTemplate = maxTickDisplay;

      rangeSlider.TickMarks.Add(maxTickMark);

 

      // Add min thumb to slider

      XamSliderNumericThumb minThumb = new XamSliderNumericThumb();

      minThumb.Name = "sliderMin";

      minThumb.InteractionMode = SliderThumbInteractionMode.Push;

      minThumb.IsSnapToTickEnabled = false;

      minThumb.Value = 0.0;

      minThumb.TrackFillBrush = new SolidColorBrush(Colors.Transparent);

      rangeSlider.Thumbs.Add(minThumb);

 

      // Add max thumb to slider

      XamSliderNumericThumb maxThumb = new XamSliderNumericThumb();

      maxThumb.Name = "sliderMax";

      maxThumb.InteractionMode = SliderThumbInteractionMode.Push;

      maxThumb.IsSnapToTickEnabled = false;

      maxThumb.Value = 10.0;

      rangeSlider.Thumbs.Add(maxThumb);