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

Not able to set SelectionStart and SelectionEnd

1 Answer 233 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Tarun Yadav
Top achievements
Rank 1
Tarun Yadav asked on 15 Oct 2009, 11:36 PM
Hi,

I am using RADSlider using DataTemplates. These data templates are applied based on the selected item in a combo box. (Combo Box has "Hour", "Day" and "Week" values. Based on the item i show the tick labels as dates.
Template looks like below:

 

 

 

<DataTemplate x:Name="DailyTickTemplate">  
            <Grid> 
                <Grid.RowDefinitions> 
                    <RowDefinition Height="Auto"/>  
                    <RowDefinition Height="Auto"/>  
                </Grid.RowDefinitions> 
                <Rectangle Grid.Row="0" Width="2" Height="6" Fill="White" Margin="0,2,0,0" VerticalAlignment="Top" /> 
                <TextBlock Grid.Row="1" Text="{Binding Converter={StaticResource DailyConverter}}" FontSize="8" Foreground="White"/>  
            </Grid> 
        </DataTemplate> 

The Problem is: When I try to set the Selection Start and Selection End of Slider from code on combobox selected item changed event, i can't do that.
Irrespective of what is assigned to selection start and selection end, it assumes some wierd values.

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 19 Oct 2009, 10:19 AM
Hi Tarun,

This is a known side effect of SelectionStart and SelectionEnd properties of RadSlider. Imagine you have a slider that initially has SelectionStart set to 0.4 and SelectionEnd set to 0.6. In the click event handler of some button, you try to reset SelectionStart and SelectionEnd by doing the following:

slider.SelectionStart = 0.7;
slider.SelectionEnd = 0.8;

The problem with the above is that when you say slider.SelectionStart = 0.7;, the coerce mechanism of the slider will be triggered. These coerces will evaluate the incoming value (0.7) and check if it is less than the Minimum, greater than the Maximum or greater than the SelectionEnd. SelectionEnd was initially 0.6
and we are now trying to set SelectionStart to 0.7. As a result of the coerces, the new SelectionStart will be 0.6 and the new SelectionEnd will be 0.8.
As a workaround, I'd suggest you first reset the SelectionStart and SelectionEnd, and then first assign the SelectionEnd and then the SelectionStart:

// reset
slider.SelectionStart = 0.0;
slider.SelectionEnd = 0.0;
 
// assign new values, order is important
slider.SelectionEnd = newSelectionEnd;
slider.SelectionStart = newSelectionStart;

Give it a try and let me know how it works for you.

Regards,
Kiril Stanoev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Slider
Asked by
Tarun Yadav
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Share this question
or