WPF Tooltip Visibility WPF Tooltip Visibility wpf wpf

WPF Tooltip Visibility


You will need to set ToolTipService.ShowOnDisabled to True on the Button in order to have the Tooltip visible at all when the Button is disabled. You can bind ToolTipService.IsEnabled on the Button to enable and disable the Tooltip.


This is the full XAML of the Button (based on the answer of @Quartermeister)

<Button   x:Name="btnAdd"   Content="Add"   ToolTipService.ShowOnDisabled="True"   ToolTipService.IsEnabled="{Binding ElementName=btnAdd, Path=IsEnabled, Converter={StaticResource boolToOppositeBoolConverter}}"   ToolTip="Appointments cannot be added whilst the event has outstanding changes."/>


You can do it using a simple trigger also. Just place the following piece of code into a Window.

<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">    <CheckBox Name="chkDisabler" Content="Enable / disable button" Margin="10" />    <Button Content="Hit me" Width="200" Height="100" IsEnabled="{Binding ElementName=chkDisabler, Path=IsChecked}">        <Button.Style>            <Style TargetType="{x:Type Button}">                <Setter Property="ToolTipService.ShowOnDisabled" Value="true" />                <Setter Property="ToolTip" Value="{x:Null}" />                <Style.Triggers>                    <Trigger Property="IsEnabled" Value="False">                        <Setter Property="ToolTip" Value="Hi, there! I'm disabled!" />                    </Trigger>                </Style.Triggers>            </Style>        </Button.Style>    </Button></StackPanel>