A universal commitment can be what you have to go, you can do what you ask. Here is one way to do this:
1. Enter your CheckBoxUid header
<CheckBox Uid="CheckAll" />
2. write your DataGrid
<DataGrid Name="myDataGrid" />
3.Use the following extension method
public static UIElement FindUid(this DependencyObject parent, string uid)
{
var count = VisualTreeHelper.GetChildrenCount(parent);
if (count == 0) return null;
for (int i = 0; i < count; i++)
{
var el = VisualTreeHelper.GetChild(parent, i) as UIElement;
if (el == null) continue;
if (el.Uid == uid) return el;
el = el.FindUid(uid);
if (el != null) return el;
}
return null;
}
4.Access and uncheck the CheckBoxcode like this
CheckBox checkBox = myDataGrid.FindUid("CheckAll") as CheckBox;
checkBox.IsChecked = false;
source
share