How to stop update value of slider while dragging it?

后端 未结 5 2527
遥遥无期
遥遥无期 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:04

    Hi this solution works for me. Just override Slider class and bind to FinalValue in xaml.

    public class ExSlider : Slider
    {
        public double FinalValue
        {
            get { return (double)GetValue(FinalValueProperty); }
            set { SetValue(FinalValueProperty, value); }
        }
    
        public static readonly DependencyProperty FinalValueProperty =
            DependencyProperty.Register(
                "FinalValue", typeof(double), typeof(ExSlider),
                new FrameworkPropertyMetadata(0d,
                    FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
    
        protected override void OnThumbDragCompleted(DragCompletedEventArgs e)
        {
            base.OnThumbDragCompleted(e);
            FinalValue = Value;
        }
    
    }
    

提交回复
热议问题