private static void DataGridCellLoaded(DataGridCell sender, RoutedEventArgs e) { DataGridCell dataGridCell = (DataGridCell)sender; if (DataGridCellHelper.GetDataGrid(dataGridCell) == null) { DataGridCellHelper.SetDataGrid(dataGridCell, dataGridCell.TryFindParent <DataGrid>()); } }
private static void CellPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { DataGridCell dataGridCell = dependencyObject as DataGridCell; if (dataGridCell != null && e.NewValue != e.OldValue && e.NewValue is bool) { dataGridCell.Loaded -= new RoutedEventHandler(DataGridCellHelper.DataGridCellLoaded); dataGridCell.Unloaded -= new RoutedEventHandler(DataGridCellHelper.DataGridCellUnloaded); DataGrid dataGrid = null; if ((bool)e.NewValue) { dataGrid = dataGridCell.TryFindParent <DataGrid>(); dataGridCell.Loaded += new RoutedEventHandler(DataGridCellHelper.DataGridCellLoaded); dataGridCell.Unloaded += new RoutedEventHandler(DataGridCellHelper.DataGridCellUnloaded); } DataGridCellHelper.SetDataGrid(dataGridCell, dataGrid); } }
private static void DataGridCellUnloaded(DataGridCell sender, RoutedEventArgs e) { DataGridCellHelper.SetDataGrid((DataGridCell)sender, null); }