Slider event for "end of sliding"


  • Hi!

    I am using Slider control to allow user modifying a value whose change will start update that takes several seconds.

    All the value changed events that I've tried fire the event as soon as the value changes, and I haven't found a way to detect whether the Slider is still active (and thus likely changing the value again).

    So I'd need solid way to catch when the sliding is done.





    Wednesday, March 07, 2007 11:58 AM


All replies

  • Have you tried subclassing the slider and overriding OnThumbDragCompleted?

    Wednesday, March 07, 2007 12:24 PM
  • Hi!

    Thanks for excellent suggestion; although I haven't done it yet I think subclassing that would be the key to get close enough.

    Being in WPF world, I had somewhat forgotten that way of customizing controls ;)




    Wednesday, March 07, 2007 5:00 PM
  • You could do what neil said with subclassing and overriding OnThumbDragComplete, but an easier solution might just be for you to stay attached to the ValueChanged event and, instead of doing your work right in that event handler, kick off a DispatcherTimer that waits half a second or whatever makes sense for you. If the timer is already kicked off, you cancel and reset it. When the timer finally ticks, you do the work you wanted to do.

    'Cause if you think about it, people don't always drag the slider anyway. Lots of people click on the slider bar or the repeat buttons to advance it a couple of ticks at a time. You don't want to go off an do your expensive work in those cases either.


    Wednesday, March 07, 2007 5:06 PM
  • I agree, good suggestion Drew!
    Wednesday, March 07, 2007 5:15 PM
  • Hi!

    Thanks for the alternative suggestion; I had actually thought of that kind of solution. The problem in my case was, that as I update the descrption field that contains the sliding value, people may keep sliding and pause while still sliding when figuring out where they should stop.

    Now in such a case unless I can detect the sliding active status, it's not clear what kind of time should be used.

    This is not against your suggestion at all, but in this case it would become more of a guessing of "best working" time delay and the end result would be not working in fixed enough way for my taste for this solution.


    I actually went around it somewhere in between; I removed the longer taking refresh action from the slider(s) (there are two of them changing different values) and added "Apply" button beside them.

    The button's IsEnabled is bound to the boolean property (I'll call it IsButtonEnabled here) that simply compares the "current effective values" with the slider changing property values. If they differ, the button is active for user to click for refreshing.

    Both the slider properties of course then send the PropertyChanged notification for the IsButtonEnabled helper property, when the sliders change their property values.


    Wednesday, March 07, 2007 5:30 PM

    Forgot to add, that delay is still valid (combined with the active slider state) for the repeat button clicks that you mention.

    So I'll likely go with both the implementations in a case I have to get rid of the refresh button.



    Wednesday, March 07, 2007 5:33 PM
  • I'm dreaming of a "RealtimeUpdate" boolean property on the slider : <Slider RealtimeUpdate="False"/>
    Maybe in next version of WPF ? :)

    This problem is very common, and having to use a timer, or to subclass the control is a lot of overhead IMHO...
    Thursday, September 04, 2008 9:19 AM