Suggestion for RadSlider

5 posts, 1 answers
  1. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 23 Jul 2008 Link to this post

    I would like to customize the display text for each tick of the slider. Instead of just the numeric values I want the steps to have individual descriptions, such as "None", "Low", "Medium", "High" etc. While I managed to do that with some trickery involving a TextBlock in the TickTemplate, catching the "Loaded" event of that textblock, using its DataContext (double) to find the right text in my own object collection, and finally changing the Text property of the TextBlock, it would be nice if that functionality was built into the component. Hope I'm making myself understood here. If not, please ask. /Henrik
  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 24 Jul 2008 Link to this post

    Hello Henrik,
    A more elegant way of achieving the desired outcome is the use of ValueConverter instead of TemplateSelector. Take a look at the attached example for better explanation and if you have any further questions or remarks, do not hesitate to contact us.

    Kind regards,
    Kiril
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 24 Jul 2008 Link to this post

    It's certainly more elegant. However, the strings I want to display for the ticks is in an object collection which is a child of the object that the slider is bound against. The data context for the Tick object is only a double. To find my string I need access to the data context of the RadSlider itself, and I don't think I can get to that in the ValueConverter.
  5. Answer
    Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 25 Jul 2008 Link to this post

    Hello Henrik,

    One way of reaching RadSlider's DataContext is to create a public property in the converter class. Then whenever you set the DataContext, get the converter from the resources and set the property mentioned above to point to that DataContext. For better understanding see the sample project I have attached.
    If you have any additional questions, contact us as soon as possible.

    Kind regards,
    Kiril
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 25 Jul 2008 Link to this post

    Yeah, you're right, that should work. Good stuff. Thanks.
Back to Top
DevCraft banner