Adding a ValueConverter to the AutoToolTip of a Slider?
Hi,
I have a Slider which displays the Value using AutoToolTip, i.e. when dragging the slider a tooltip shows the current value, e.g. "80".
The XAML for the slider currently looks as follows:
Code Snippet<Slider Grid.ColumnSpan="3" Grid.Row="2" TickPlacement="BottomRight" Value="{Binding Path=SelectedItem.MaxUsePercent, ElementName=ListView, Mode=Default}" LargeChange="10" Maximum="100" SmallChange="1" TickFrequency="10" AutoToolTipPlacement="BottomRight"/>Now, I want to make the AutoToolTip show another text, such as "80% used". The question is, how do I achieve this? Is there any way of adding a ValueConverter to the AutoToolTip?
Thanks.
Answers
I just blogged about a solution to this problem: http://joshsmithonwpf.wordpress.com/2007/09/14/modifying-the-auto-tooltip-of-a-slider/
HTH
Your solution worked great! Many thanks. I wonder why Microsoft hasn't added a solution for this to the standard Slider control. Being able to format and control the AutoToolTip text seems like a quite common thing to do?
All Replies
- AutoToolTipPlacement:
Gets or sets whether a tooltip that contains the current value of the Slider displays when the Thumb is pressed. If a tooltip is displayed, this property also specifies the placement of the tooltip.
So if you set the ToolTip for the Slider, that value will be displayed
Code Snippet<Slider AutoToolTipPlacement="BottomRight" ToolTip="Hi :-)" />
Setting AutoToolTipPlacement="BottomRight" will enable the AutoToolTip, which will make the ToolTip display the current Value when the Thumb is pressed. I've already done this if you check my code above. However, I don't just want the Value (e.g. "80") to be displayed, I want the ToolTip do display the string "80% used" when the thumb is pressed.
Also, adding ToolTip="Hi :-)" as you suggested will only display that string when the mouse hoovers over the slide, which is not what I want.
Any other suggestions?

I just blogged about a solution to this problem: http://joshsmithonwpf.wordpress.com/2007/09/14/modifying-the-auto-tooltip-of-a-slider/
HTH
Your solution worked great! Many thanks. I wonder why Microsoft hasn't added a solution for this to the standard Slider control. Being able to format and control the AutoToolTip text seems like a quite common thing to do?


