Select datagrid row programmatically

Oct 8, 2009 at 4:59 PM
I'm looking for a way to select a datagrid row through code and have
it's row details expand.

This is somewhat related to my previous post /How to freeze expanded
Rowdetails/ which I'm not getting any help with.

Ideally, I'd like any expanded rowdetails to remain expanded when
refreshing the grid data by setting the ItemsSource, but if that's not
possible, I'll take some workaround that gets the user back to where he
was; like selecting the row he had previously selected.

I'm able to save the DataGridRow (and the DetailsElement for that
matter) when the LoadingRowDetails event is handled. I can get the
DataGridRow and DetailsElement from the DataGridRowDetailsEventArgs, but
then you can't seem to do anything with it later (like after the grid
refresh.) The obvious methods to try were BringIntoView and Focus (on
both the DataGridRow and DetailsElement) but neither of those worked in
any combination.

Any help appreciated here, thanks.