C# WPF : slider going to exact position

TheQuestioner picture TheQuestioner · Aug 2, 2013 · Viewed 9.8k times · Source

I'm using a slider in a WPF window and I want that when the user clicks somewhere on the track of the slider, the thumb to go to that exact position. Currently, when I click somewhere, the thumb goes towards that position, but not to exactly that position. How can I achieve what I want ?

Edit: An example to better explain what I want: If the thumb is at 10 and I press the mouse down near 100 , I want it to jump to 100 (without passing through other values).

Answer

Bolu picture Bolu · Aug 2, 2013

you need to set IsMoveToPointEnabled to True: http://msdn.microsoft.com/en-us/library/system.windows.controls.slider.ismovetopointenabled.aspx

Slider.IsMoveToPointEnabled Gets or sets a value that indicates whether the Thumb of a Slider moves immediately to the location of the mouse click that occurs while the mouse pointer pauses on the Slider track.