private CheckBox GenerateCheckBox(bool isEditing, DataGridCell cell) { var checkBox = (cell != null ? cell.Content as CheckBox : null) ?? new CheckBox { Template = (ControlTemplate)cell.TryFindResource("CheckMarkControlTemplate") }; checkBox.IsThreeState = IsThreeState; ApplyStyle(isEditing, true, checkBox); checkBox.SetBinding(ToggleButton.IsCheckedProperty, Binding); return(checkBox); }