0

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.

Michel Feinstein
  • 13,416
  • 16
  • 91
  • 173
  • im not familiar with the xceed datagrid, but the built in wpf datagrid hierarchy doesn't give access to the column from the row without doing some special visual/logic tree gymnastics. perhaps look back up to the Cell parent? – Kevin Nacios Jun 17 '15 at 01:49
  • I guess I will have to look at its template to find the visual tree – Michel Feinstein Jun 17 '15 at 01:56
  • Yeah, I can't see it in the Control Template, so I guess it's not there....I also tried `AncestorLevel` (from 1 to 7) and it just throws an exception. – Michel Feinstein Jun 17 '15 at 03:57

0 Answers0