views:

42

answers:

1

How do I change the selected row programatically?

I change change the selected item and cell, but I cannot figure out how to get the whole row highlighted.

Note: The highlighting works fine when a user selects a row with mouse or keyboard.

A: 

take a look at this page. You need both the SelectionUnit and SelectionMode to specify how the selection is done in the DataGrid.

With SelectionUnit = FullRow and SelectionMode = Single, the user can only select one row at a time.

edit: after trying it out, it looks as though DataGrid.SelectedItem[i] will select an entire row. Unfortunately, it looks as if you will have to manually set the highlight in an event handler that you have to create for the SelectionChanged property of the DataGrid.

vlad
I already have those settings, the highlighting works fine when a user selects a row with mouse or keyboard. I need to know how to change the selection using code.
Jonathan Allen