views:

706

answers:

1

In a dialog from my application, I have an observable collection (stored somewhere else) bound to a list of tabs. When I close and reopen the dialog, the currently selected tab gets lost and winds up to the be the first one. How do I set up my tabs so that the selected tab persists?

I had the impression that the observable collection had "current item" property, but that doesn't seem to be case. I've looked at ItemCollection and CollectionView, which do have a current item property, but I'm not sure if that's that I'd be interested in.

+1  A: 

In the Closing event of your dialog, save away the currently selected TabItem.

In the Loaded event of your dialog, simply say:

yourTabControl.SelectedItem = _savedTab;

Code-behind is the easiest way to accomplish this. ObservableCollection is not going to help you.

Charlie