This is a migrated thread and some comments may be shown as answers.

DragStarted/DragStopped events

3 Answers 122 Views
Slider
This is a migrated thread and some comments may be shown as answers.
hwsoderlund
Top achievements
Rank 1
hwsoderlund asked on 01 Oct 2008, 11:40 AM
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?

3 Answers, 1 is accepted

Sort by
0
hwsoderlund
Top achievements
Rank 1
answered on 01 Oct 2008, 01:00 PM
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); 
        } 
 
    } 

0
hwsoderlund
Top achievements
Rank 1
answered on 01 Oct 2008, 01:06 PM
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.
0
Accepted
Kiril Stanoev
Telerik team
answered on 06 Oct 2008, 06:53 AM
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.
Tags
Slider
Asked by
hwsoderlund
Top achievements
Rank 1
Answers by
hwsoderlund
Top achievements
Rank 1
Kiril Stanoev
Telerik team
Share this question
or