How to make a ToolTip not bigger than it's Control?

100 views Asked by At

I have a Xceed DataGrid, and in one of the Columns there is a text that can be very long. I want to show just part of the text, and if the user hovers the mouse on top of it, a Tooltip will show the entire text.

I am trying to set the ToolTip's MaxWidh like this:

    <DataTemplate x:Key="TooltipTextBlockTemplate">
        <TextBlock Text="{Binding}" x:Name="DataTextBlock">
            <TextBlock.ToolTip>
                <TextBlock Text="{Binding}" TextWrapping="Wrap" MaxWidth="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type xcdg:Column}}}" />
            </TextBlock.ToolTip>            
        </TextBlock>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding}" Value="">
                <Setter TargetName="DataTextBlock" Property="ToolTipService.IsEnabled" Value="False"  />
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

I have tried AncestorType={x:Type xcdg:Column}}}" and AncestorType={x:Type TextBlock}}}" but it just expands to the whole screen.

0

There are 0 answers