WPF 绑定 DataGrid 里面 Button点击事件 TextBlock 双击事件

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);
 }
相关推荐
rockey6272 小时前
AScript如何实现LINQ语法
sql·c#·.net·linq·script·eval·expression
xiaoshuaishuai82 小时前
C# CDN加速与离线包优化PowerSetting慢问题
开发语言·windows·spring·c#
烈焰猩猩6 小时前
【无标题】
c#
njsgcs6 小时前
制作solidworks插件 装配体导出展开耗时分析
开发语言·c#·solidworks
njsgcs6 小时前
c# solidworks 标注攻牙
开发语言·c#·solidworks
吴可可1238 小时前
点在线上判定与多段线分割
算法·c#
吴可可1238 小时前
圆弧多段线离散化采样密度优化
算法·c#
雪豹阿伟11 小时前
4.C# —— 循环语句、break、continue
c#·上位机
两千次11 小时前
webpost
c#
她说彩礼65万12 小时前
WPF Border
wpf