[Version 2.0] AnchorableSource Updated Callback?

Jun 1, 2014 at 8:09 AM
Edited Jun 1, 2014 at 8:11 AM
I'm using AvalonDock with Prism (and MEF) to build the modularized UI of my application:
  • Prism/MEF loads modules from a folder with module dll files;
  • Each module registers a tool pane to an ObservableCollection<PaneViewModel>, which is the AnchorableSource of the DockingManager;
  • The layout of DockingManager is automatically loaded on app startup and saved while app terminates;
  • A LayoutUpdateStrategy is specified so once an Anchorable is being inserted, the strategy tries to find a LayoutContent which has the same ContentId with the Anchorable to insert, and replaces the LayoutContent with the Anchorable, thus the Anchorables will be placed to the correct place.
Now everything is working well except for one thing, if one (or more) module has been removed from the module folder, because its previous location is saved in the layout, there will be a empty pane on the next time the app starts, the user has to close it manually.
So I guess there should be a chance at which I can traverse through the layout and remove the empty panes, which is essentially:
            var emptyLayoutContents = this.DockingManager
                                          .Where(c => c.Content == null)
            foreach(var emptyLayoutContent in emptyLayoutContents)
However, I cannot find a correct chance to do this. DockingManager.LayoutUpdated won't work, because at that time the modules are still not loaded (AnchorableSource not updated). I guess the best chance is right after AnchorableSource has been updated, is there such an event or something for me to do that?

Any thought on this is appreciated.