隐藏提示如果结合为null [英] Hide tooltip if binding is null

查看:101
本文介绍了隐藏提示如果结合为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我已经得到了以下code显示工具提示。

Currently i've got the following code to show a tooltip.

<Border BorderBrush="Black"
        BorderThickness="{Binding Border}"
        Height="23"
        Background="{Binding Color}">
<ToolTipService.ToolTip>
    <TextBlock Text="{Binding TooltipInformation}" />
</ToolTipService.ToolTip>

这是一个ItemsControl的psented约25个项目$ P $。只有少数的这些都设置为 TooltipInformation

This is presented in a ItemsControl with about 25 items. Only a few of these have a value set to TooltipInformation

如果 TooltipInforation 是一个空字符串,它仍然显示了一个包含文本块作为一个很小的窗口tooltipbox(约5像素高,20像素宽)。即使我设置文本​​块visbility到崩溃。

If TooltipInforation is an empty string, it still shows the tooltipbox containing the textblock as a very small window (about 5px high and 20px wide). Even if I set the textblock visbility to collapsed.

有没有办法彻底删除提示如果TooltipInformation的值为null或一个空字符串?

Is there a way to completely remove the tooltip if the value of TooltipInformation is null or a empty string?

推荐答案

您可以做到这一点的方法之一是在长方形包裹工具提示 ,并给它一个透明颜色。然后,你刚才设置的能见度折叠在此长方形

One way you can do that is wrap the ToolTip in a Rectangle and give it a Transparent color. Then you just set the Visibility to Collapsed on this Rectangle.

更新:

<Border Background="#FFE45F5F">
    <Grid>
        <TextBlock Text="{Binding Property1}"/>
        <Rectangle Fill="Transparent" Visibility="{Binding Property2, Converter={StaticResource BooleanToVisibilityConverter}}" ToolTipService.ToolTip="{Binding TooltipInformation}"/>
    </Grid>
</Border>

这篇关于隐藏提示如果结合为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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