Assuming that I have a tabcontrol with several tabitems and the implementation is based on this and using usercontrols for each tabs like this. MVVM light is also used.
How to notify in a proper way (mvvm) the tabitems that the application is closing by clicking on (x) in order to save data for each tab? I know how to handle a closing event in the MainWindow which hosts the tabitems but I don't know how to notify the UserControl(actually its viewmodel) for each tabitem. Any idea? Moreover if the tabitem is not selected and showed on the screen, will be notified for the closing?
Solved
I followed the @3615 solution in the comments of this question. Using Messenger which is based on Mediator pattern. So my MainViewModel listens for a window closing event and broadcasts the information to the tabitems.