xceedsoftware / wpftoolkit

All the controls missing in WPF. Over 1 million downloads.
Other
3.9k stars 878 forks source link

Nested AvalonDock DockingManagers causes ContextMenu to throws System.ComponentModel.Win32Exceptions #1660

Closed DonTickner closed 3 years ago

DonTickner commented 3 years ago

Apologies if this has been raised, I wasn't able to find an existing open issue for this. The scenario is having an AvalonDock DockingManager contain a LayoutDocument that itself contains a DockingManager. After using the Document ContextMenu on the nested DockingManager, and then mousing over any other control, a System.ComponentModel.Win32Exception is thrown. This is easily repeatable in a new project by simply nesting DockingManagers as described.

image

image

The specific exception message was: "System.ComponentModel.Win32Exception: 'Invalid window handle'". This exception was originally thrown at this call stack: MS.Win32.UnsafeNativeMethods.GetWindowText(System.Runtime.InteropServices.HandleRef, System.Text.StringBuilder, int).

Once the above behaviour has been triggered, simply moving the window can trigger an enormous stream of these exceptions.

Reviewing the documentation, I can't see any mention of nesting being indirectly or expressly prohibited, and so I believe this to be an issue.

XceedBoucherS commented 3 years ago

Hi, Thank you for pointing this out. We will have a look into this. It must be an issue. Thank you.

XceedBoucherS commented 3 years ago

Hi,

Here's the sample we are using. It has a DockingManager, containing LayoutDocuments, where one of them contains a DockingManager with LayoutDocuments.

When using the drop down menu on the right of the LayoutDocument of the nested DockingManager(or right click on the LayoutDcument tabs), the output do not show any exception.

We are using Toolkit v4.0.2 from NuGet.

Can you confirm or modify the sample in order to reproduce your issue ? Thank you. test.txt

DonTickner commented 3 years ago

Hi @XceedBoucherS Thank you for the reply, and apologies for the delay in coming back to you. I recently changed development machines, and using this new machine and fresh installs, I have been completely unable to replicate the errors I reported.

The specific project was a custom UserControl that housed a Grid and a DockingManager. The UserControl was set as the content of a LayoutDocument within another DockingManager in code-behind. This allowed the end user a dynamic amount of nesting, and appeared to create the error I reported.

Apologies for the time wasted on this - I'm not sure what was triggering this error, however I cannot re-create it. If I am able to replicate this, or determine what the cause was, I'll reach out.

Thank you, and apologies again. Don

XceedBoucherS commented 3 years ago

no problem. Thank you