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

Move to Point and range selection issue

3 Answers 90 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Nicole
Top achievements
Rank 1
Nicole asked on 14 Feb 2012, 09:37 PM
We have a RadSlider defined as follows:

<telerik:RadSlider x:Name="sldTimeSelection" Grid.Row="1" Grid.Column="0" Orientation="Horizontal"  
                   Minimum="-365" Maximum="0" IsMoveToPointEnabled="True"
                   IsSelectionRangeEnabled="True" MinimumRangeSpan="7" MaximumRangeSpan="365" 
                   SelectionStart="-30" SelectionEnd="0"
                   IsSnapToTickEnabled="True" TickPlacement="BottomRight" Ticks="-7, -30, -90, -180, -365" EnableSideTicks="False" Margin="5,0" >
</telerik:RadSlider>

Move to Point works perfectly with the mouse when expanding the slider range in the decrease direction.  However, if you click inside the range itself, neither handle moves.  This makes sense, since the control has no way of knowing which handle you want to move.  However, I want to lock the increase handle (per my other thread) and allow the user to click inside the range to move the decrease handle to a high value.

For example, the slider starts at -30 to 0.
I click on/near the -90 tick and the range is now -90 to 0, which is good.
I click on/near the -30 tick, and the range does not move.  The desired behavior is for the range to become smaller at -30 to 0.

Is this possible?

3 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Stanoev
Telerik team
answered on 16 Feb 2012, 02:34 PM
Hi Nicole,

With a little bit of code I managed to implement the scenario you're looking for. Could you please take a look at the attached project and let me know if it works for you.

All the best,
Kiril Stanoev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Nicole
Top achievements
Rank 1
answered on 16 Feb 2012, 04:05 PM
This works beautifully, thanks!

0
Nicole
Top achievements
Rank 1
answered on 27 Feb 2012, 04:50 PM
A quick modification for posterity -- the additional lines prevent mouse clicks which are in the window but not on the control from moving the slider.

private void Slider_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    var frameworkEl = e.OriginalSource as FrameworkElement;
    if (frameworkEl != null)
    {
        var container = frameworkEl.ParentOfType<RadSlider>();        
        if (container != null)
        {
            var width = container.ActualWidth;
            var mousePosition = e.GetPosition(this.sldTimeSelection);
            var value = ((this.sldTimeSelection.Maximum - this.sldTimeSelection.Minimum) * (mousePosition.X - width)) / width;
            this.sldTimeSelection.SelectionStart = this.SnapToTick(value);
        }
    }
}
Tags
Slider
Asked by
Nicole
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Nicole
Top achievements
Rank 1
Share this question
or