我在列表框内的图像上有一个工具提示。工具提示设置如下:
<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”
有任何想法吗?
最佳答案
你不需要额外的{}
ContentStringFormat
中的前缀.与 ToolTip
,也更喜欢使用 ContentStringFormat
而不是 StringFormat
在绑定(bind)中。
以下作品:
<Image.ToolTip>
<ToolTip Content="{Binding}"
ContentStringFormat="Ping: {0}ms" />
</Image.ToolTip>
关于WPF 图像工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4847734/