WPF-具有字符串格式的工具提示绑定 [英] WPF - ToolTip Binding with stringformat

查看:44
本文介绍了WPF-具有字符串格式的工具提示绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用绑定和字符串格式做一个工具提示,他就是我尝试过的:

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}{}'}"/>

Name的值为:

戈兰

我希望看到的是:

名称是:戈兰

The name is: Golan

但所看到的是:

戈兰

推荐答案

我认为您可以使用此代码

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>

这篇关于WPF-具有字符串格式的工具提示绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆