How to Select All CheckBox of a Column by DataGrid Header CheckBox in WPF DataGrid

后端 未结 4 937
[愿得一人]
[愿得一人] 2020-12-17 22:54

I have a DataGrid with one CheckBoxColumn. In the header of that CheckBoxColumn I have added a CheckBox to Select all CheckBoxes of that Datagrid Row.

How can I achi

4条回答
  •  独厮守ぢ
    2020-12-17 23:20

    I have added CheckBox to Select all CheckBox in Datagrid Row

    if you mean select all checkbox in datagrid column, then i would say: simply update your itemssource collection with checked/unchecked.

    public bool SelectAll
    {
      get{return this._selectAll;}
      set
      {
         this._selectAll = value;
         this.MyItemsSourceCollection.ForEach(x=>x.MyRowCheckProperty=value);
         this.OnPropertyChanged("SelectAll");
      }
    }
    

    xaml

            
                
                    
                
                
                    
                        
                    
                
            
    

    i dunno if the xaml bindings are right, but i hope you can see my intention

提交回复
热议问题