WPF - ToolTip Binding with stringformat

这一生的挚爱 提交于 2019-12-23 22:19:59

问题


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:


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>


来源:https://stackoverflow.com/questions/34509627/wpf-tooltip-binding-with-stringformat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!