I'm using the WPF toolkit datagrid. I have it set to SelectionUnit="Cell" and SelectionMode="Extended".
The SelectionChanged event is never raised!
It works fine when the SelectionUnit is set to FullRow.
Am I Missing something?
BTW, the reason I need it is since I'm trying to create an Attached Property to help me bind the SelectedCells to my ViewModel.
Make use of DataGrid.SelectedCellsChanged
which should provide you with what you need.
private void DG1_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
{
//Get the newly selected cells
IList<DataGridCellInfo> selectedcells = e.AddedCells;
//Get the value of each newly selected cell
foreach (DataGridCellInfo di in selectedcells)
{
//Cast the DataGridCellInfo.Item to the source object type
//In this case the ItemsSource is a DataTable and individual items are DataRows
DataRowView dvr = (DataRowView)di.Item;
//Clear values for all newly selected cells
AdventureWorksLT2008DataSet.CustomerRow cr = (AdventureWorksLT2008DataSet.CustomerRow)dvr.Row;
cr.BeginEdit();
cr.SetField(di.Column.DisplayIndex, "");
cr.EndEdit();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With