views:

173

answers:

2

I've made a time slider in Silverlight. To style it, I've made a control template and modified the style. I've added a text field above the thumb (always centered above the thumb), which should display the time.

However, I can't find any way to access the slider information (e.g. current value) or find another way to pass any information to the style, which I can then data bind to the text field.

So my question in short: how can I display time information above the thumb?

A: 

I believe the only way to do that is to create a control class that derives from Slider, and then create a dependency property on that class that maps the slider's value to a time value. Then you can databind your template to that property.

ErikHeemskerk
A: 

I've found a solution that worked for my project. I have (mis)used the Tag property of the slider and put the time information in it. I then databound this to a textblock in the template, displaying the information.

It's not the most elegant solution, but it was sufficient for the job. Maybe I will choose to put the entire slider inside a user control, as @ErikHeemskerk suggested.

Scharrels