Hi all,
cc @curtisw
We have been struggling with behavioral differences on Panels between Rhino7 and Rhino8. We were using Panels.Closed
event in Rhino7 to be able to handle different ways of panel closing to unregister properly WebView
from WpfElementHost
as below.
private void PanelsOnClosed(object? sender, PanelEventArgs e)
{
if (e.PanelId == typeof(SpeckleRhinoPanelHost).GUID)
{
// This check comes from behavioral difference on closing Rhino Panels.
// IsPanelVisible returns;
// - True, when docked Panel closed from the list on right click on panel tab,
// whenever it is closed with this way, Rhino.Panels tries to reinit this object and expect the different UIElement, that's why we disconnect Child.
// - False, when detached Panel is closed by 'X' close button.
// whenever it is closed with this way, Rhino.Panels don't create this object, that's why we do not disconnect Child UIElement.
if (!Panels.IsPanelVisible(typeof(SpeckleRhinoPanelHost).GUID))
{
return;
}
// Unsubscribe from the event to prevent growing registrations.
Panels.Closed -= PanelsOnClosed;
// Disconnect UIElement from WpfElementHost. Otherwise, we can't reinit panel with same DUI3ControlWebView
if (_webView != null)
{
// Since WpfHost inherited from Border, find the parent as border and set null it's Child.
if (LogicalTreeHelper.GetParent(_webView) is Border border)
{
border.Child = null;
}
}
}
But on Rhino8 we are not catching this event whenever we close panel from X button on detached panel mode or Close button when detached.
Is there any new API functions that we need to aware of or it is a bug with Panels?
Best