I love WPF

"jamais sans son interface"

I love WPF

"jamais sans son interface"

ToolTips with StringFormat when it’s don’t work

If you want bind a tooltip with value and have a StringFormat of a slider for exemple… the StringFormat is not apply (for tag or another property it’s the same behavior)
For solve it use this code

<Slider x:Name="slider"
        HorizontalAlignment="Left"
        Background="LightCoral"
        Height="29"
        Margin="37,162,0,0"
        TickFrequency="1"
        Tag="{Binding Value, RelativeSource={RelativeSource Self}, StringFormat=N2}"
        VerticalAlignment="Top"
        Value="0"
        Width="350">
        <Slider.ToolTip>
           <ToolTip DataContext="{Binding Path=PlacementTarget, RelativeSource={RelativeSource Self}}">
              <TextBlock Text="{Binding Value, StringFormat=N2}" />
            </ToolTip>
        </Slider.ToolTip>
 </Slider>

tag is set for see result

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Retour en haut