This behavior will only happen when you drag the large slider pointer, this is by design.
However, here is the code that will do this -)
Connect to the MouseMove event in XAML:
<Slider MouseMove="Slider_OnMouseMove" IsMoveToPointEnabled="True"/>
Then paste this code:
private void Slider_OnMouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { var slider = (Slider)sender; Point position = e.GetPosition(slider); double d = 1.0d / slider.ActualWidth * position.X; var p = slider.Maximum * d; slider.Value = p; } }
Note:
- You may have to take the fields and fill in your slider into account, if they differ, I donβt know.
- This was done on a horizontal slider.
- The minimum value of my slider was 0, make sure you adjusted the calculation if your minimum is negative.
- Finally, it only works if IsMoveToPointEnabled is installed.
source share