During the change of focus from the DataGrid to the button, the binding update at CurrentCell triggered
I select a row with a column triggered
Binding CurrentCell(In the VM, theDatagridCellInfoupdated)I click on the button to work again
Binding CurrentCell(How not to let it work?) (The VM updatesDatagridCellInfotonull), it should not seem like a code (Althoughupdatesourcetotriger=propertychanged) and then
My XAML DataGrid :
<DataGrid ItemsSource="{Binding Path=Collection}" SelectedItem="{Binding Path=SelectedPlaneMonth}" IsReadOnly="{Binding Path=IsReadOnly}" AutoGenerateColumns="False" CurrentCell="{Binding Path=DataGridCell, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ColumnWidth="*"/> My VM Code on CurrentCell
public DataGridCellInfo DataGridCell { get => _dataGridCell; set { _dataGridCell = value; OnPopertyChanged("DataGridCell"); if (_dataGridCell.Column != null) { CheckBox content = _dataGridCell.Column.GetCellContent(_dataGridCell.Item) as CheckBox; if (content.IsChecked == true) { IsEnableButton = true; } else { IsEnableButton = false; } } } } My VM code on the ChangedCommand Button
public PosukCommand ChangedCommand { get { return _changedCommand ?? (_changedCommand = new PosukCommand(obj => { if (_dataGridCell.Column != null) { using (PosukContext db = new PosukContext()) { PprCalendarPalneMonth palneMonth = _dataGridCell.Item as PprCalendarPalneMonth; var _day = palneMonth.GetType().GetField("Day" + _dataGridCell.Column.DisplayIndex.ToString()); } } })); } }