TextBlock双击事件
<DataGridTemplateColumn Width="*" Header="内标"><DataGridTemplateColumn.CellTemplate><DataTemplate><Grid><TextBlockBackground="Transparent"Tag="{Binding InternalId}"Text="{Binding InternalId}"><TextBlock.InputBindings><MouseBindingCommand="{Binding DataContext.InternalClickCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"CommandParameter="{Binding}"MouseAction="LeftDoubleClick" /></TextBlock.InputBindings></TextBlock></Grid></DataTemplate></DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Button点击事件
<DataGridTemplateColumn Width="*" Header="内标"><DataGridTemplateColumn.CellTemplate><DataTemplate><Grid><ButtonBackground="Transparent"BorderBrush="Transparent"Command="{Binding Path=DataContext.InternalClickCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"Content="{Binding InternalId}"Tag="{Binding InternalId}" /></Grid></DataTemplate></DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
[RelayCommand]private void InternalClick(GuantifyCompound guantifyCompound){MessageBox.Show("=InternalClick=" + guantifyCompound.LeftWidth);}