I have a view (I'll call it MainView) that contains a TabControl. The views that make up the TabItems are created using prism view discovery in MainView's ViewModel. Each of the views that are "tabs" have some cleanup that needs to be done (detaching event handlers, etc.) when I'm done with the tab control (i.e. during the MainView's Unloaded event). However, I can't do the cleanup with the Tab views' Unloaded event, as this is called when just switching tabs.
MainView is calling a method on its ViewModel when Unloaded fires, but that ViewModel does not have a reference to the Views or ViewModels that make up the tabs due to the way those views are registered. What is the proper way to clean up after my "discovered" tab views?