While upgrading our WPF plug-ins to Rhino 6, we’re seeing a significant change in how the WpfElementHost is working that we thought would be worth documenting. In Rhino 5, the WpfElementHost class constructor seems to be called just once, which is the first time that the dockable panel is opened. In Rhino 6, we notice now that every time a document is changed, if the dockable panel is opened, the WpfElementHost constructor is is called. This occurs before any document-related event is fired (so before NewDocument, BeginOpenDocument, EndOpenDocument).
We also noticed that view models bound to the WpfElementHost don’t appear to be disposed at this point. So we have a RhinoEntry class that manages how our plug-ins interact with selection, object creation/deletion, and document related events. What we’ve found is that instances of this class bound to our view models remain alive and well even after new models are bound to the user control, and their event listening continues. So if our users change documents multiple times, as many of our RhinoEntry classes exist behind the scenes. We’ve adapted for this by relocating this class as a static class in our plug-in, but thought it was worth noting this change in behavior.