WPF: Slider doesnt raise MouseLeftButtonDown or MouseLeftButtonUp

后端 未结 4 1951
傲寒
傲寒 2021-01-04 01:02

I tried this XAML:



        
4条回答
  •  隐瞒了意图╮
    2021-01-04 01:29

    I'd like to mention that the Slider doesn't quite swallow the entire MouseDown event. By clicking on a tick mark, you can get notified for the event. The Slider won't handle MouseDown events unless they come from the slider's... slider.

    Basically if you decide to use the

    AddHandler(Slider.MouseLeftButtonDownEvent, ..., true)
    

    version with the ticks turned on, be sure that the event was handled previously. If you don't you'll end up with an edge case where you thought the slider was clicked, but it was really a tick. Registering for the Preview event is even worse - you'll pick up the event anywhere, even on the white-space between ticks.

提交回复
热议问题