WPF图像工具提示 [英] WPF Image Tooltip
本文介绍了WPF图像工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在列表框内的图像上有工具提示。工具提示设置如下:
I have a tooltip on an image inside of a listbox. The tooltip is setup as follows:
<Image Grid.Column="0" Source="{Binding PingRankImage}"
Width="16" Height="16"
HorizontalAlignment="Center" VerticalAlignment="Center">
<Image.ToolTip>
<ToolTip Content="{Binding Ping, StringFormat='Ping: {0}ms'}"
ContentStringFormat="{}Ping: {0}ms}" />
</Image.ToolTip>
</Image>
但工具提示只显示值,而不是'Ping:XXXms'
but the tooltip just displays the value and not the 'Ping: XXXms'
任何想法?
推荐答案
您不需要额外的 { }
前缀 ContentStringFormat
。使用 ToolTip
,也更喜欢使用 ContentStringFormat
而不是 StringFormat
绑定。
You don't need extra {}
prefix in ContentStringFormat
. With ToolTip
, also prefer using ContentStringFormat
instead of StringFormat
in binding.
以下作品:
<Image.ToolTip>
<ToolTip Content="{Binding}"
ContentStringFormat="Ping: {0}ms" />
</Image.ToolTip>
这篇关于WPF图像工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文