Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF - ToolTip Binding with stringformat

I want to make a tool tip using binding and string format, he is what I've tried:

<TextBlock Text="{Binding Name}"
           ToolTip="{Binding Path=Name, StringFormat='The name is: {0}{}'}"/>

The value of Name is :

Golan

What I expected to see is:

The name is: Golan

But all is see is:

Golan

like image 839
Golan Kiviti Avatar asked Dec 25 '22 11:12

Golan Kiviti


1 Answers

I think you can use this code

<TextBlock Width="100" x:Name="tt" Text="{Binding Name}">
    <TextBlock.ToolTip>
        <ToolTip  Width="100"
            Content="{Binding Name}"
            ContentStringFormat="The Name is: {0}"
        />
    </TextBlock.ToolTip>
</TextBlock>
like image 61
Justin CI Avatar answered Dec 27 '22 19:12

Justin CI