要求:DataGrid的CheckBox列单击任CheckBox可以绑定到后台Command,并且单击就能改变
(默认的DataGridCheckBoxColumn需要单击二次,才有勾选,否选效果)

在尝试了自定义CellEditTemplate,DataGridCheckBoxColumn之后选择下面的方法

1,问题Mode=TwoWay,在CellTemplate不起做用 ,所以在后台Command,要赋值,才能达到最终效果

<DataGridTemplateColumn CanUserSort="False" HeaderStyle="{DynamicResource chkAll}" >
  <DataGridTemplateColumn.CellTemplate>
  <DataTemplate>
    <CheckBox IsChecked="{Binding IsSelect, Mode=OneWay}"
          Command="{Binding DataContext.SingleJobSelectCommand,
            RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
          CommandParameter="{Binding}"
          HorizontalAlignment="Center" VerticalAlignment="Center" >
    </CheckBox>
  </DataTemplate>
  </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

相关文章:

  • 2022-12-23
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-29
  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
  • 2022-01-20
  • 2022-01-24
相关资源
相似解决方案