Datagrid Column header should check / uncheck CheckBox’s state depending upon whether all CheckBoxes of a DataGridView column are checked or unchecked

后端 未结 2 1196
北荒
北荒 2020-12-06 06:30

\"enter The problem i\'m stuck with is related to checkbox in DataGrid(WPF). I\'ve attached th

2条回答
  •  鱼传尺愫
    2020-12-06 07:07

    In your XAML Datagrid add:

    
    
    
    

    In your code add:

    var ckbox = sender as CheckBox;
    var All = Collection.View.SourceCollection as List;
    
    if (ckbox.IsChecked)
    {
        foreach (var item in All)       
            item.Marked = true;     
    }
    else
    {
        foreach (var item in All)       
            item.Marked = false;        
    }
    Collection.View.Refresh();
    

    NOTE: The sender is CheckBox

提交回复
热议问题