效果图如下:
主要是调用ToolTipService.ToolTip属性
主要代码如下:
<sdk:DataGrid Margin="4,36,8,7" DataContext="{Binding}" IsReadOnly="True" AutoGenerateColumns="False" x:Name="dg" SelectionChanged="dg_SelectionChanged" FontSize="14.667" FontFamily="Microsoft YaHei" LoadingRow="dg_LoadingRow" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden" d:LayoutOverrides="HorizontalMargin">
<sdk:DataGrid.Columns>
<sdk:DataGridTemplateColumn Header="序号" Width="50" HeaderStyle="{StaticResource aHeaderStyle}">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Center" VerticalAlignment="Center">
<ToolTipService.ToolTip>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" Foreground="Red" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</ToolTipService.ToolTip>
</TextBlock>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
<sdk:DataGridTemplateColumn Header="工程名称" Width="200" HeaderStyle="{StaticResource aHeaderStyle}">
<TextBlock FontSize="14.667" Text="{Binding Name}" HorizontalAlignment="Left" VerticalAlignment="Center">
<ToolTipService.ToolTip>
</sdk:DataGrid.Columns>
</sdk:DataGrid>