Finding where the user moved from

3 posts, 1 answers
  1. PaulH
    PaulH avatar
    26 posts
    Member since:
    Mar 2011

    Posted 20 Dec 2012 Link to this post

    Hi there.

    I have a Silverlight app that makes use of a Slider, bound to the current time position of a media item. I want to track the user's use of the system for analytics. One such event is when a user clicks on the slider to move to a new position. I've been using the MouseLeftButtonDown event but with that I can only determine where the user has moved the slider to and not where it's come from. I need to know both values. I had tried setting a flag in the MouseLeftButtonDown event and then checking that in the ValueChanged event but by the time ValueChanged fired the old and new values were a fraction apart and at a position after where the user had clicked to. I don't want to simply rely on the ValueChanged event as that fires so frequently and I need to know only when the user has manually moved position. Is there a way to determine what the position was that the user moved from?

    Thanks in advance.
  2. Answer
    Kiril Vandov
    Kiril Vandov avatar
    323 posts

    Posted 21 Dec 2012 Link to this post

    Hello Paul,

    It is possible to get the previous position using the ValueChanged  event but as you mentioned it fires too quickly and implementing logic to calculate the previous position could cause performance issues.
    private const int updateTime = 1;
    void RadSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        currentVideoPosition = slider.Value;
        if (currentVideoPosition - previousVideoPosition < updateTime)
            previousVideoPosition = currentVideoPosition;
    And then when you click you will have the two values.

    However there is another approach. Basically , RadSlider is mainly consisted of RepeatButton, Thumb, and second RepeatButton. You acntually see these three when you use RadSlider with no additional properties set.
    So you could get these Repeat buttons from the template of RadSlider. Then, in their Click event handlers, get the RadSlider Value property and store it in field. After that the ValueChanged event will update the Slider's Value and then the Slider's MouseLeftButtonDown event will be triggered.

    I am attaching you a sample project for your convenience.

    Hope this information help.

    Kind regards,
    Kiril Vandov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft R3 2016 release webinar banner
  4. PaulH
    PaulH avatar
    26 posts
    Member since:
    Mar 2011

    Posted 24 Dec 2012 Link to this post

    Hi and thanks. I've implemented your suggestions and it's now doing what I want. Excellent.

    And a Merry Christmas and Happy New Year to all.
Back to Top