How can I add ToolTip to my project using materialdesign.xaml and DragablzItem property

44 Views Asked by At

I have tabs that are 90% made from library Infragistics and it's documents which are locked, so they are read-only. I use C# and XAML for WPF Application and I want to add ToolTip as a message every time when my mouse goes over the tab, to show a little message as a comment what can user expect when he clicks on that tab. Can someone help me with these, please? :)

<Style x:Key="DragablzItemStyle" BasedOn="{StaticResource MaterialDesignDragableTabItemStyle}" TargetType="{x:Type dragablz:DragablzItem}" >
     <Setter Property="Foreground" Value="{Binding ThemeMainForeground, Source={x:Static app:App.Instance}}"/>
     <Setter Property="IsEnabled" Value="{Binding DataContext.IsVersionActive, RelativeSource={RelativeSource AncestorType={x:Type dragablz:TabablzControl}}}"/>
     <Style.Triggers>
         <Trigger Property="IsEnabled" Value="False">
             <Setter Property="Opacity" Value="0.6"/>
         </Trigger>
         <Trigger Property="IsSelected" Value="False">
             <Setter Property="Background" Value="transparent"/>
             <Setter Property="Foreground" Value="#bebebe"/>
         </Trigger>
         <Trigger Property="IsMouseOver" Value="True">
             <Setter Property="Background" Value="#FFE5E5E5"/>
             <Setter Property="Foreground" Value="{Binding ThemeMainForeground, Source={x:Static app:App.Instance}}"/>
             <ToolTipService.ToolTip>
                 <ToolTip Content="Tooltip Text Here"/>
             </ToolTipService.ToolTip>
         </Trigger>
     </Style.Triggers>
 </Style>

This is a style that I want to use and I tried to add ToolTip here but it didn't show up.

1

There are 1 best solutions below

1
Legkov Ivan On

Content controls have a ToolTip property, which you can set in your style:

<Style x:Key=...>
    <Setter Property="ToolTip" Value="Hi" />
    <!-- Other stuff-->
</Style>    

And if you want, you can set ToolTip property to a custom ToolTip control of your liking:

<Style x:Key=...>
    <Setter Property="ToolTip">
        <Setter.Value>
            <ToolTip
                Background="DimGray"
                Content="Hi"
                FontStyle="Italic"
                Foreground="White" />
        </Setter.Value>
    </Setter>
    <!-- Other stuff-->
</Style>