I have an MVVM application using tabs like Josh Smith's example. Each TabItem (View) represents an individual ViewModel.
On some Views there are DataGrids that are bound to ObservableCollections. So far everything works fine. But when I start to edit a data grid, e.g. by typing into a cell, and before hitting 'enter' to submit the changes, switch to another tab, I cannot really get back to the previous tab. The Tab content changes but the tabitem remains unselected. I guess I somehow have to stop the editing mode of the datagrid, but how do I do that in an MVVM app? For an ICollectionViewSource I know I could do it like this
IEditableCollectionView list = (ListCollectionView)this.ItemsView;
if (list.IsEditingItem) list.CommitEdit();
if (list.IsAddingNew) list.CommitNew();
but I cant do this for an ObservableCollection. Do I have to change the Binding to a view of the observable collection or is there another way?