Changing the tick labels based on a dropdown

3 posts, 0 answers
  1. Tarun Yadav
    Tarun Yadav avatar
    6 posts
    Member since:
    Oct 2009

    Posted 08 Oct 2009 Link to this post

    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. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 09 Oct 2009 Link to this post

    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.
  3. DevCraft banner
  4. Tarun Yadav
    Tarun Yadav avatar
    6 posts
    Member since:
    Oct 2009

    Posted 13 Oct 2009 Link to this post

    Thanks Kiril
    I got the clue, it worked.
Back to Top