Articles in this section
Category / Section

How to change the CheckBox value for all SelectedItems when any selected CheckBox value changed in WinRT DataGrid?

1 min read

By using CurrentCellValueChanged event, you can change the CheckBox value for all selected rows, when you are changing any one of the CheckBox value.

C#

this.datagrid.CurrentCellValueChanged += Datagrid_CurrentCellValueChanged;
 
private void Datagrid_CurrentCellValueChanged(object sender, CurrentCellValueChangedEventArgs args)
{
    if (datagrid.View == null)
        return;           
 
    if (!this.datagrid.SelectionController.CurrentCellManager.HasCurrentCell)
        return;
 
    IPropertyAccessProvider reflector = datagrid.View.GetPropertyAccessProvider();
 
    var dataColumn = datagrid.SelectionController.CurrentCellManager.CurrentCell;
    if (dataColumn.GridColumn != null && dataColumn.GridColumn is GridCheckBoxColumn)
    {
        var currentRecord = this.datagrid.GetRecordAtRowIndex(dataColumn.RowIndex);
        var mappingName = dataColumn.GridColumn.MappingName;
        var currentCellCheckboxValue = reflector.GetValue(currentRecord, mappingName);
        foreach (var item in datagrid.SelectedItems)
        {
            reflector.SetValue(item, mappingName, currentCellCheckboxValue);
        }
    }
}
 

 

Graphical user interface, table

Sample Links:

WPF

WinRT

UWP

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied