Fix: volume slider click-to-position restored
Skip Thumb clicks (let drag work normally), set value + e.Handled on track clicks so the RepeatButton's IncreaseLarge/DecreaseLarge can't override the jumped-to position. 207 tests, 0 warnings.
This commit is contained in:
@@ -123,11 +123,14 @@ public partial class MainWindow : Window
|
||||
|
||||
private static void SetSliderValueFromClick(Slider slider, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.OriginalSource is System.Windows.Controls.Primitives.Thumb)
|
||||
return;
|
||||
var track = slider.Template.FindName("PART_Track", slider) as System.Windows.Controls.Primitives.Track;
|
||||
if (track == null) return;
|
||||
var pos = e.GetPosition(track);
|
||||
var fraction = Math.Clamp(pos.X / track.RenderSize.Width, 0, 1);
|
||||
slider.Value = slider.Minimum + fraction * (slider.Maximum - slider.Minimum);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void MicSpeaker_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user