views:

30

answers:

1

It is a simple task in another grid, but I can't make it happen in WPF DataGrid. There are UnselectAll or UnselectAllCells methods, but don't work. Also, setting SelectedItem = null or SelectedIndex = -1 don't work either.

There is a post here about completely disable selection, but that's not what I want. I just want to clear the current selection (if any) and set a new selection programmatically.

A: 

Use this code: MyDataGrid.SelectedItems.Clear();

vorrtex