我有一个包含多列的数据网格。当用户将鼠标悬停在其中一列的单元格上时,我想显示工具提示。 这是我尝试过的代码:
<DataGridTextColumn Binding="{Binding PackageName}" MinWidth="250" IsReadOnly="True" ElementStyle="{StaticResource ResourceKey=StyleDataGridText}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Background" Value="#E3E3E3"/>
</Style>
</DataGridTextColumn.HeaderStyle>
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="ToolTip" Value="{Binding Info}" />
</Style>
</DataGridTextColumn.CellStyle>
<DataGridTextColumn.Header>
<DockPanel>
<TextBlock Text="Package Name"/>
<Image x:Name="SortPackageNameImg" Source="{StaticResource SortupImg}" Width="10" Height="10" Margin="10,0,0,0"></Image>
<Button Name="PackageNameFilterBtn" Click="PackageNameFilter_Click" HorizontalAlignment="Right" Margin="0,0,10,0">
<Button.Template>
<ControlTemplate>
<Image Source="/Resources/filter.png" Width="10" Height="10"/>
</ControlTemplate>
</Button.Template>
</Button>
</DockPanel>
</DataGridTextColumn.Header>
</DataGridTextColumn>
但这不起作用。有什么我需要改变来解决这个问题吗?