How to stop update value of slider while dragging it?

后端 未结 5 2543
遥遥无期
遥遥无期 2021-02-20 12:21

I\'ve slider that its value is bind to some property, and the property updates it all the time. While dragging the [thumb on] slider I want to stop this update value of slider f

5条回答
  •  星月不相逢
    2021-02-20 13:01

    I had the same issue so I made a simple slider extension as the next best thing. Adds two events to the slider:

    ThumbDragStarted ThumbDragCompleted

    public class SliderWithDraggingEvents : Slider
    {
        public delegate void ThumbDragStartedHandler(object sender, DragStartedEventArgs e);
        public event ThumbDragStartedHandler ThumbDragStarted;
    
    
        public delegate void ThumbDragCompletedHandler(object sender, DragCompletedEventArgs e);
        public event ThumbDragCompletedHandler ThumbDragCompleted;
    
        protected override void OnThumbDragStarted(DragStartedEventArgs e)
        {
            if (ThumbDragStarted != null) ThumbDragStarted(this, e);
            base.OnThumbDragStarted(e);
        }
    
        protected override void OnThumbDragCompleted(DragCompletedEventArgs e)
        {
            if (ThumbDragCompleted != null) ThumbDragCompleted(this, e);
            base.OnThumbDragCompleted(e);
        }
    }
    

提交回复
热议问题