|
this.sfDataGrid.CellRenderers.Remove("CheckBox");
this.sfDataGrid.CellRenderers.Add("CheckBox", new GridCellCheckBoxRendererExt());
public class GridCellCheckBoxRendererExt : GridCellCheckBoxRenderer
{
public override void OnInitializeEditElement(DataColumnBase dataColumn, CheckBox uiElement, object dataContext)
{
base.OnInitializeEditElement(dataColumn, uiElement, dataContext);
uiElement.Click += OnClicked;
}
private void OnClicked(object sender, RoutedEventArgs e)
{
var checkBox = (e.OriginalSource as CheckBox);
var mappingName = (checkBox.Parent as GridCell).ColumnBase.GridColumn.MappingName;
//get the rowdata
var rowData = checkBox.DataContext;
//here customize based on your scenario
if (mappingName == "IsClosed")
(rowData as OrderInfo).IsSelected = !(bool)checkBox.IsChecked;
else if (mappingName == "IsSelected")
(rowData as OrderInfo).IsClosed = !(bool)checkBox.IsChecked;
}
} |