Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nonlinear WPF Slider values

Tags:

wpf

xaml

slider

It is straightforward to remap the linear values returned by a WPF slider control:

public double Multiplier
{
  get
  {
    switch ((int)sliderMultiplier.Value)
    {
      case 0: return 0.1;
      case 1: return 0.2;
      case 2: return 0.5;
      case 3: return 1;
      case 4: return 2;
      case 5: return 5;
      case 6: return 10;
      default: throw new ArgumentOutOfRangeException();
    }
  }
}

But the slider handle, while being dragged, is accompanied by a tooltip showing the selected value - the unmapped linear value. How can I supply the remapped value for display? Or get the slider to supply non-linear values directly?

like image 295
Peter Wone Avatar asked May 20 '26 19:05

Peter Wone


1 Answers

Somebody else has solved this (as far as the tooltips are concerned). Couldn't find a way of having the slider itself actually report a non-linear value range.

http://joshsmithonwpf.wordpress.com/2007/09/14/modifying-the-auto-tooltip-of-a-slider/

like image 156
paul Avatar answered May 24 '26 17:05

paul