It looks like the diagram selection is cleared as the diagram is getting unloaded from the visual tree. This is problematic when your diagram is inside of a TabControl and you’re propogating the selection to an external selection manager. Here’s what happens in Silverlight when you switch tabs:
Diagram runs internal Unloaded event handler
Selection is cleared, causing a Diagram.SelectionChanged event (this is where my external selection manager gets screwed)
The internal Unloaded event handler will always be first in the list of delegates so the selection will always be cleared. I suppose I could set Diagram.UnloadClearsPartManager=True, but I was hoping to actually unload all of those parts and potentially regain some memory. Is it possible in the next release to either not clear the selection when unloading or provide a flag similar to UnloadClearsPartManager (say, UnloadClearsSelection) that prevents that behavior while still allowing the PartManager to be cleared?
I was able to work around this using a pair of Blend SDK behaviors that use the Prism messaging channel, but its fairly convoluted and seems fragile.