c# code for select all checkbox in wpf datagrid

后端 未结 5 1537
一个人的身影
一个人的身影 2020-12-15 00:17

I need some c# code to select / deselect all checkboxes in a datagrid in WPF 3.5 framework. I would like to do this by clicking a single header checkbox in the grid.

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-15 00:29

    This can be done declaratively. The following creates a checkbox column for each row and which can toggle row selections. The header of the checkbox column can be clicked to do a select all of the rows.

    Relevant portions from the xaml

    
        
        
           
               
                   
               
           
        
        
    
    

提交回复
热议问题