Reputation: 2994
I am creating a WinRT/Windows 8 app that needs a slider with both bottom and top tickbars and a number label below each tick as well indicating the value of each tick.
So far I have got the slider with the colors and the tickbars working but I cannot get the labels below the tickbars working.
I know that there was some way to do this in WPF by creating a default class and inheriting it and overriding OnRender but I don't think that will work in WinRT since there is no DrawableContext class.
If anyone has done something like this, please help!
PS: The labels just need to have a single value and not a range value as shown in the image and so does the thumb.
Thanks
Upvotes: 4
Views: 2496
Reputation: 1947
Here's how it's done in WPF: http://social.msdn.microsoft.com/Forums/vstudio/en-US/8d64b2dc-4dfd-4b05-aa95-e24aaaed53af/i-want-to-add-lables-with-text-in-ticks-of-slider
Correct, there's no OnRender() in WinRT XAML. As Tim points out, you can retemplate Slider and make your own custom TickBar. It can override ArrangeOverride() and create custom tick marks using Line or Rectangle with labels created using TextBlock. If you don't need a generic solution, you could just overlay the Slider with TextBlocks for the labels.
Upvotes: 1
Reputation: 4301
In order to get the UI you want, you'll have to re-template the Slider and TickBar within it do get the values to show.
Upvotes: 1