开发者

Displaying current time above the thumb of a slider in Silverlight

开发者 https://www.devze.com 2023-01-03 23:28 出处:网络
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 dis

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开发者_StackOverflow中文版) 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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消