WPF - ToolTip Binding with stringformat

2019-07-18 07:56发布

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

1条回答
Ridiculous、
2楼-- · 2019-07-18 08:32

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>
查看更多
登录 后发表回答