隐藏提示如果结合为null [英] Hide tooltip if binding is 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屋!