New to Telerik UI for WPF? Download free 30-day trial

Hide Empty Tooltips in SelectionBoxTemplate

Environment

Product Version 2019.3 1216
Product RadComboBox for WPF

Description

How to show SelectionBox tooltip only when the tooltip has content.

Solution

To achieve the desired result, you can add a DataTrigger to set the Tooltip to null when the corresponding property is an empty string. For example, you can define the SelectionBoxTemplate as follows:

<DataTemplate x:Key="SelectionBoxTemplate"> 
    <TextBlock Text="{Binding Name}"> 
        <TextBlock.Style> 
            <Style TargetType="TextBlock"> 
                <Setter Property="ToolTip" Value="{Binding Tooltip}" /> 
                <Style.Triggers> 
                    <DataTrigger Binding="{Binding Tooltip}" Value=""> 
                        <Setter Property="ToolTip" Value="{x:Null}" /> 
                    </DataTrigger> 
                </Style.Triggers> 
            </Style> 
        </TextBlock.Style>                     
    </TextBlock> 
</DataTemplate> 

See Also

In this article