Dirkster99 / AvalonDock

Our own development branch of the well known WPF document docking library
Microsoft Public License
1.41k stars 321 forks source link

Drop a Floating Window reload the content #424

Open Safirion opened 1 year ago

Safirion commented 1 year ago

I have an ActiveX component that can't be unloaded/reloaded after being initialized.

With avalon dock, content of floating Windows are unloaded and reloaded when droped instead of being reused.

Can be reproduced with Test Project named "TestApp" by adding an unloaded event on the winformsIntegration:WindowsFormsHost

<LayoutAnchorablePane DockWidth="50">
                        <LayoutAnchorable x:Name="WinFormsWindow"
                            Title="WinForms Window"
                            CanClose="False"
                            CanHide="False"

                            ContentId="WinFormsWindow"
                            ToolTip="My WinForms Tool">
                            <winformsIntegration:WindowsFormsHost x:Name="winFormsHost" Background="White" Unloaded="WinFormsHost_OnUnloaded" />
                        </LayoutAnchorable>
                    </LayoutAnchorablePane>

The unloaded event is not triggered when drag the tab to FloatingWindow so the problem is only when drop the floating window to a tab.

When I tried the VS2013Test project, it is event worse because it recreate pane content on drag and on drop.

Is there any option that I've missed or workaround to don't reload content at drag/drop ?

Thank you by advance

romen-h commented 1 year ago

This issue affects me, but I don't think there is a good way around it. Changing the window for a control involves removing the control from one logical tree and adding it on another logical tree. WPF's API calls Load/Unload itself when you do that, not called by AvalonDock directly.