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

Changing the tick labels based on a dropdown

2 Answers 50 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 09 Oct 2009, 01:59 AM
Is it possible to change the tick labels in a slider control based on selected item in a drop down control?

I am using a Slider control and using the Tick template for assigning tick labels. I want to change the tick labels based on the currently selected item in a drop down.

2 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 09 Oct 2009, 11:51 AM
Hello Tarun,

Yes, it is possible to change the TickTemplate at runtime. You simply have to attach to the SelectionChanged event of your drop-down(assuming you are using ComboBox control) and pass the DataContext of the selected item as a DataTemplate to the TickTemplate property of RadSlider.
For example, assume you have drop-down similar to the one bellow:

<ComboBox x:Name="comboBox" SelectionChanged="ComboBox_SelectionChanged">
    <ComboBoxItem>
        <ComboBoxItem.Content>
            <Image Source="Images/emoticon1.png" />
        </ComboBoxItem.Content>
        <ComboBoxItem.DataContext>
            <DataTemplate>
                <Image Source="Images/emoticon1.png" />
            </DataTemplate>
        </ComboBoxItem.DataContext>
    </ComboBoxItem>
</ComboBox>

Then, in ComboBox_SelectionChanged:

ComboBoxItem comboBoxItem = comboBox.SelectedItem as ComboBoxItem;
DataTemplate tickTemplate = comboBoxItem.DataContext as DataTemplate;
slider.TickTemplate = tickTemplate;

I have attached my sample project for further reference. Give it a try and let me know how it works for you.

Sincerely yours,
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.
0
Tarun Yadav
Top achievements
Rank 1
answered on 14 Oct 2009, 12:06 AM
Thanks Kiril
I got the clue, it worked.
Tags
Slider
Asked by
Tarun Yadav
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Tarun Yadav
Top achievements
Rank 1
Share this question
or