Skip to content

Add CanDockAsDocument to IDockable#996

Merged
wieslawsoltes merged 4 commits intomasterfrom
issue-902-candockasdocument
Jan 22, 2026
Merged

Add CanDockAsDocument to IDockable#996
wieslawsoltes merged 4 commits intomasterfrom
issue-902-candockasdocument

Conversation

@wieslawsoltes
Copy link
Copy Markdown
Owner

PR Summary: Add CanDockAsDocument

Summary

This change introduces CanDockAsDocument on IDockable to let dockables opt out of being docked as tabbed documents. The flag is enforced during docking validation and when invoking DockAsDocument, exposed in Avalonia UI bindings, and documented with tests to cover the expected behavior.

Implementation Details

  • Added CanDockAsDocument to IDockable and all model base classes, with defaults set to true.
  • Updated Avalonia JSON serializer property lists to include the new flag.
  • Added a fluent setter WithCanDockAsDocument for easy configuration.
  • Enforced the flag in DockManager validation so dockables that opt out cannot dock into IDocumentDock or IDocument targets.
  • Guarded FactoryBase.DockAsDocument so programmatic docking respects the flag.
  • Updated Fluent theme context menus and the diagnostics dockable debug view to surface the flag.

Key files:

  • src/Dock.Model/Core/IDockable.cs
  • src/Dock.Model/DockManager.cs
  • src/Dock.Model/FactoryBase.Dockable.cs
  • src/Dock.Model/FluentExtensions.cs
  • src/Dock.Model.Avalonia/Core/DockableBase.cs
  • src/Dock.Model.Avalonia/Json/AvaloniaDockSerializer.cs
  • src/Dock.Avalonia.Themes.Fluent/Controls/ToolChromeControl.axaml
  • src/Dock.Avalonia.Themes.Fluent/Controls/ToolPinItemControl.axaml
  • src/Dock.Avalonia.Themes.Fluent/Controls/ToolTabStripItem.axaml
  • src/Dock.Avalonia.Diagnostics/Controls/DockableDebugView.axaml

Usage

View model / code

var tool = new Tool
{
    Id = "Explorer",
    Title = "Explorer",
    CanDockAsDocument = false
};

Fluent configuration

tool.WithCanDockAsDocument(false);

Behavior notes

  • When CanDockAsDocument is false, docking into IDocumentDock or IDocument targets is rejected.
  • DockAsDocument does nothing for dockables with CanDockAsDocument = false.
  • The “Dock as Tabbed Document” context menu item is hidden for dockables that opt out.

Tests

Covered by new/updated tests:

  • tests/Dock.Avalonia.HeadlessTests/DockManagerTests.cs
  • tests/Dock.Avalonia.HeadlessTests/DockManagerDocumentTests.cs
  • tests/Dock.Avalonia.HeadlessTests/FactoryDockAsDocumentTests.cs
  • tests/Dock.Model.UnitTests/DockGroupValidationTests.cs

Notes

  • This flag is intended for docking-as-document scenarios only. Other docking rules (drag/drop, docking groups, pinning, floating) are unchanged.

Fixes #902

@wieslawsoltes wieslawsoltes merged commit e9bec48 into master Jan 22, 2026
8 checks passed
@wieslawsoltes wieslawsoltes deleted the issue-902-candockasdocument branch January 22, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CanDockAsDocument to IDockable

1 participant