.NET Framework Developer Center > .NET Development Forums > Windows Presentation Foundation (WPF) > Adding a ValueConverter to the AutoToolTip of a Slider?
Ask a questionAsk a question
 

AnswerAdding a ValueConverter to the AutoToolTip of a Slider?

  • Friday, September 14, 2007 10:48 AMJohn Fredman_ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    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

All Replies

  • Friday, September 14, 2007 12:02 PMFrances83 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    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 Smile

    Code Snippet

    <Slider AutoToolTipPlacement="BottomRight" ToolTip="Hi :-)" />


  • Friday, September 14, 2007 12:22 PMJohn Fredman_ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    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? Wink

  • Friday, September 14, 2007 1:45 PMJosh SmithMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
  • Monday, September 17, 2007 8:16 AMJohn Fredman_ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    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?