Moving the current item in a ListBox

I’ve been using ListBoxes with IsSynchronizedWithCurrentItem property set to True to do a lot of master/detail views recently.  When using MVVM with Command Pattern it’s wasn’t immediately obvious to me how to manipulate which item was selected when I added/removed etc from the list.

If I’ve just created a client record and added it to my ObservableCollection of Clients in my viewModel I can use CollectionViewSource to get a hold of the view and manipulate the current item e.g.

CollectionViewSource.GetDefaultView(viewModel.Clients).MoveCurrentTo(client);
Technorati Tags: ,