DragStarted/DragStopped events

4 posts, 1 answers
  1. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 01 Oct 2008 Link to this post

    I'm having some problems detecting when the sliders thumb is dragged. What I'm trying to do is display a tooltip for each of the sliders ticks. I need to know when dragging starts and when it stops to show/hide the tooltip. Is this possible?
  2. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 01 Oct 2008 Link to this post

    I solved this by extending RadSlider and adding the two events manually (see the code below). Please consider adding these two events to the component in a future version.

    public class ExtendedRadSlider : RadSlider 
        { 
            /// <summary> 
            /// Fired when the thumb has been clicked, and dragging is initiated 
            /// </summary> 
            public event EventHandler<EventArgs> ThumbDragStarted; 
     
            /// <summary> 
            /// Fired when the thumb has been released 
            /// </summary> 
            public event EventHandler<EventArgs> ThumbDragCompleted; 
             
            public ExtendedRadSlider() 
                : base() 
            { 
                DefaultStyleKey = typeof(RadSlider); 
            } 
     
            public override void OnApplyTemplate() 
            { 
                base.OnApplyTemplate(); 
     
                //Set up drag event handlers 
                Thumb thumb = this.GetTemplateChild("HorizontalSingleThumb"as Thumb; 
                if (thumb != null
                { 
                    thumb.DragStarted += new DragStartedEventHandler(thumb_DragStarted); 
                    thumb.DragCompleted += new DragCompletedEventHandler(thumb_DragCompleted); 
                } 
            } 
     
            void thumb_DragCompleted(object sender, DragCompletedEventArgs e) 
            { 
                OnThumbDragCompleted(thisnew EventArgs()); 
            } 
     
            void thumb_DragStarted(object sender, DragStartedEventArgs e) 
            { 
                OnThumbDragStarted(thisnew EventArgs()); 
            } 
     
            protected virtual void OnThumbDragStarted(object sender, EventArgs e) 
            { 
                if (ThumbDragStarted != null
                    ThumbDragStarted(sender, e); 
            } 
     
            protected virtual void OnThumbDragCompleted(object sender, EventArgs e) 
            { 
                if (ThumbDragCompleted != null
                    ThumbDragCompleted(sender, e); 
            } 
     
        } 

  3. DevCraft banner
  4. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 01 Oct 2008 Link to this post

    I forgot to mention that the code above does not handle the vertical layout or the range selection mode. If someone needs help implementing support for that, I'll be happy to post a sample.
  5. Answer
    Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 06 Oct 2008 Link to this post

    Hello Henrik,

    Thank you very much for you interest in our controls suite. We will definitely consider implementing the events you mentioned for the next version of the controls. Your points have been updated as per our EAP Program.

    Kind regards,
    Kiril Stanoev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top