wpf <DataGridTemplateColumn> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <CheckBox HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding IsCheck,UpdateSourceTrigger=PropertyChanged}" x:Name="DTCB" Command="{Binding DataContext.SelectedCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding Cad_No}"> <CheckBox.InputBindings> <MouseBinding MouseAction="LeftClick" /> </CheckBox.InputBindings> </CheckBox> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn>怎么设置让第一行不显示mouseaction
时间: 2024-01-11 13:02:51 浏览: 295
你可以在第一个 `<MouseBinding>` 元素中添加一个 `CommandParameter` 属性,将它的值设置为一个不执行任何操作的命令(如 `"{x:Null}"`),这样当鼠标点击第一行时,不会执行任何操作。
以下是修改后的代码示例:
```
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding IsCheck, UpdateSourceTrigger=PropertyChanged}"
x:Name="DTCB"
Command="{Binding DataContext.SelectedCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
CommandParameter="{Binding Cad_No}">
<CheckBox.InputBindings>
<MouseBinding MouseAction="LeftClick"
CommandParameter="{x:Null}" />
</CheckBox.InputBindings>
</CheckBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
```
阅读全文