开发者

WPF Image Tooltip

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">开发者_JS百科;
    <Image.ToolTip>
        <ToolTip Content="{Binding Ping, StringFormat='Ping: {0}ms'}"
                    ContentStringFormat="{}Ping: {0}ms}" />
    </Image.ToolTip>
</Image>

but the tooltip just displays the value and not the 'Ping: XXXms'

Any ideas?


You don't need extra {} prefix in ContentStringFormat. With ToolTip, also prefer using ContentStringFormat instead of StringFormat in binding.

Following works:

<Image.ToolTip>
    <ToolTip Content="{Binding}"
                ContentStringFormat="Ping: {0}ms" />
</Image.ToolTip>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜