Skip to content

LayoutSyncBridge: anchorable added at runtime ignores the side of its tool dock #670

Closed

Description

@sharpSteff

Describe the bug

With DockingManager.DockLayout bound, an anchorable added to a tool dock of the MVVM layout at runtime does not go to the side of its tool dock. It lands in the pane of the active content instead (or another fallback pane), e.g. at the bottom although its tool dock is aligned right.

LayoutSyncBridge.OnAnchorableCollectionChanged adds the item to the anchorables source first and records its side in the content-to-side map afterwards:

if (!_anchorableModels.Contains(item))
    _anchorableModels.Add(item);          // the manager inserts the anchorable here and asks the strategy
if (addSide.HasValue)
    _contentToSide[item] = addSide.Value; // the side is known only now

Adding to _anchorableModels makes the DockingManager insert the anchorable right away. DockAlignmentStrategy does not find the side in the map yet and returns false, so the manager's fallback places it (pane of the active content, then a pane on the right, ...). RebuildAnchorablesFromTree has the same order. Anchorables present when the layout is bound are not affected: Attach() builds the map before it sets the sources.

Steps to reproduce

  1. Bind DockLayout of a plain DockingManager to a DockLayoutService layout with a right and a bottom toolbox.
  2. Dock the bottom toolbox in a pane and make it the active content.
  3. Add another toolbox to the right tool dock's VisibleDockables at runtime.
  4. The new toolbox appears in the bottom pane.

Expected behavior

The new toolbox goes to the side of its tool dock (right), as it would had it been there when the layout was bound.

Environment

  • AvalonDock 5.0.2 (source/Components/AvalonDock/LayoutSyncBridge.cs)
  • .NET 10, Windows 11

Activity

  1. added a commit that references this issue on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions