Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

Edited Issue: [AvalonDock 2.1] Unable to dynamically properly add tools [20833]

$
0
0
Referring to AvalonDock 2.1 (Commit 106497), I setup a simple window with a DockManager.
```

<xcad:DockingManager
AnchorablesSource="{Binding Path=Tools}"
>
<xcad:DockingManager.Theme>
<xcad:AeroTheme />
</xcad:DockingManager.Theme>
<xcad:DockingManager.LayoutUpdateStrategy>
<local:LayoutInitializer />
</xcad:DockingManager.LayoutUpdateStrategy>
<xcad:LayoutRoot>
<xcad:LayoutPanel Orientation="Vertical">
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutDocumentPane />
</xcad:LayoutPanel>
</xcad:LayoutPanel>
</xcad:LayoutRoot>
</xcad:DockingManager>
```

The goal is to be able to dynamicall add anchorable tools at run time, in the proper location.
The AnchorablesSource property is bound to an observable collection of ITool. ITool exposes a property specifying the preferred location for the tool. The LayoutInitializer attempts to position the tool in the proper pane when it is loaded.

In the attached example, the Window's Onloaded event simulates an user that attempts to load a couple of tools. My current implementation correctly behaves when a left tool is loaded before a bottom tool. Instead, it fails if the bottom tool is loaded first.

Any suggestion/bug fix/workaround would be appreciated.
Comments: ** Comment from web user: BoucherS **

Hi,

From what I can read in the AvalonDock code, there are some optimizations that could explain your problems.

In the situation that works (Bottom + Left):
- Bottom is added to the LayoutPanel Vertical and a GarbageCollect is done (nothing special).
- Left is added to the LayoutPanel Horizontal and a GarbageCollect is done (nothing special).

In the situation that doesn't works (Left + Bottom):
- Left is added to the LayoutPanel Horizontal and a GarbageCollect is done (LayoutPanel vertical is removed).
- Bottom is added to the LayoutPanel Vertical which doesn't exists.

The bug is in DockingManager.anchorablesSourceElementsChanged(), at the end, calling Layout.CollectGarbage();

This LayoutRoot.CollectGarbage() will remove "supposed" unused panels.
In section "#region collapse single child layout panels", you will notice that LayoutPanelVertical has only 1 children (a LayoutPanel Horizontal). The LayoutPanel Vertical will become Horizontal with the children from LayoutPanelHorizontal.

Remove this "section" and your sample will work. Or do not call LayoutRoot.CollectGarbage() from DockingManager.anchorablesSourceElementsChanged().


Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>