TextBlock双击事件
csharp
<DataGridTemplateColumn Width="*" Header="内标">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<TextBlock
Background="Transparent"
Tag="{Binding InternalId}"
Text="{Binding InternalId}">
<TextBlock.InputBindings>
<MouseBinding
Command="{Binding DataContext.InternalClickCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"
CommandParameter="{Binding}"
MouseAction="LeftDoubleClick" />
</TextBlock.InputBindings>
</TextBlock>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Button点击事件
csharp
<DataGridTemplateColumn Width="*" Header="内标">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<Button
Background="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>
csharp
[RelayCommand]
private void InternalClick(GuantifyCompound guantifyCompound)
{
MessageBox.Show("=InternalClick=" + guantifyCompound.LeftWidth);
}