Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dock.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<Project Path="samples/DockReactiveUIDiSample/DockReactiveUIDiSample.csproj" />
<Project Path="samples/DockReactiveUIRoutingSample/DockReactiveUIRoutingSample.csproj" />
<Project Path="samples/DockReactiveUISample/DockReactiveUISample.csproj" />
<Project Path="samples/DockReactiveUIManagedSample/DockReactiveUIManagedSample.csproj" />
<Project Path="samples/DockSimplifiedFluentSample/DockSimplifiedFluentSample.csproj" />
<Project Path="samples/DockSimplifiedSample/DockSimplifiedSample.csproj" />
<Project Path="samples/DockSplitViewSample/DockSplitViewSample.csproj" />
Expand Down
1 change: 1 addition & 0 deletions docfx/articles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Dock supports a wide range of UI patterns:
- Tool panes that auto-hide, pin, or float.
- Split layouts with proportional sizing and drag handles.
- Floating windows with docking indicators.
- Managed floating windows hosted inside the main window.
- Persisted layouts that restore across sessions.

## Key features
Expand Down
2 changes: 2 additions & 0 deletions docfx/articles/dock-floating-adorners.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ AppBuilder.Configure<App>()
When enabled `AdornerHelper` creates a lightweight `DockAdornerWindow` positioned above the drag source. The window is transparent and not topmost, so the drag preview window still appears above the adorner because only the preview is marked as `Topmost`.

Use this option if dock targets fail to appear when dragging over native controls or popups. The default value is `false` which uses an `AdornerLayer` inside the same window.

In managed window mode (`DockSettings.UseManagedWindows = true`), the floating adorner is rendered inside `ManagedWindowLayer` instead of a native window.
15 changes: 15 additions & 0 deletions docfx/articles/dock-host-window-locator.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ windows work without extra setup, but it also overwrites any locators you
configured earlier. Disable `InitializeFactory` if you want to provide your own
locators up front.

## Managed windows

Dock can host floating windows inside the main window (managed mode). When
`DockSettings.UseManagedWindows` is enabled, the default locator returns a
`ManagedHostWindow` instead of a native `HostWindow`. You can still override the
locator or provide your own window factory via `DockControl.HostWindowFactory`.

Managed windows also require `DockControl.EnableManagedWindowLayer` and a
`ManagedWindowLayer` template part. See the [Managed windows guide](dock-managed-windows-guide.md)
for setup details and [Managed windows reference](dock-managed-windows-reference.md)
for API information.

In managed mode, floating windows are rendered using the MDI layout system, so
they remain part of the main visual tree and reuse the same theme resources.

## Fallback locator

If no entry matches the provided key, `GetHostWindow` calls
Expand Down
49 changes: 49 additions & 0 deletions docfx/articles/dock-managed-windows-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Managed Windows Guide

Managed windows host floating docks inside the main window instead of spawning native OS windows. When enabled, Dock uses the in-app MDI layer to render floating windows as `MdiDocumentWindow` controls.

## When to use managed windows

Managed windows are useful when:

- Your app should stay inside a single top-level window.
- You want consistent window chrome across platforms.
- Native window restrictions or airspace issues make OS windows undesirable.

The main window is still an OS window. Managed windows affect only floating dock windows.

## How managed windows work

1. `DockSettings.UseManagedWindows` switches floating windows to `ManagedHostWindow`.
2. `DockControl` registers its `ManagedWindowLayer` with the factory when `EnableManagedWindowLayer` is true.
3. `ManagedHostWindow` creates a `ManagedDockWindowDocument` that wraps the `IDockWindow` model.
4. `ManagedWindowLayer` renders managed windows using `MdiLayoutPanel` and `MdiDocumentWindow`.

The managed windows remain in the main visual tree so they can share styles and resources with the rest of the app.

## Interaction parity

Managed windows reuse the same interaction model as native windows:

- Dragging and resizing are handled by `MdiDocumentWindow` and its layout manager.
- Dock targets, drag previews, and pinned windows are rendered inside the managed layer.
- Window magnetism and bring-to-front behavior apply within the managed layer.

## Differences from native windows

Managed windows are not OS windows:

- They do not appear in the taskbar or window switchers.
- They cannot be moved outside the main window or across monitors.
- Owner relationships and OS-level z-order do not apply; ordering uses `MdiZIndex`.

## Theming and templates

`ManagedWindowLayer` is part of the `DockControl` template and must be named `PART_ManagedWindowLayer`. If you replace the template, include the layer and keep `EnableManagedWindowLayer` set to `true` so floating windows remain visible.

## Related articles

- [Managed windows how-to](dock-managed-windows-howto.md)
- [Managed windows reference](dock-managed-windows-reference.md)
- [Floating windows](dock-windows.md)
- [MDI document layout](dock-mdi.md)
75 changes: 75 additions & 0 deletions docfx/articles/dock-managed-windows-howto.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Managed Windows How-To

This guide walks through enabling managed windows and wiring the managed window layer into your layout.

## Enable managed windows

Set the global flag before creating layouts:

```csharp
using Dock.Settings;

DockSettings.UseManagedWindows = true;
```

Or configure it via `AppBuilder`:

```csharp
using Dock.Settings;

AppBuilder.Configure<App>()
.UsePlatformDetect()
.UseManagedWindows();
```

## Ensure the managed layer is present

The built-in Dock themes include a `ManagedWindowLayer` in the `DockControl` template. If you provide a custom template, keep the part and name it `PART_ManagedWindowLayer`.

```xml
<controls:DockControl EnableManagedWindowLayer="True" />
```

Custom template snippet:

```xml
<controls:ManagedWindowLayer x:Name="PART_ManagedWindowLayer"
IsVisible="False" />
```

If you disable `EnableManagedWindowLayer`, managed floating windows will not appear.

## Provide a managed host window (optional)

If you override host window creation, return `ManagedHostWindow` when managed windows are enabled:

```csharp
dockControl.HostWindowFactory = () => new ManagedHostWindow();
```

You can also supply a factory mapping through `IFactory.HostWindowLocator` or `IFactory.DefaultHostWindowLocator`.

## Customize managed window layout

`ManagedWindowLayer` uses `ClassicMdiLayoutManager` by default. You can swap it with your own implementation:

```csharp
managedWindowLayer.LayoutManager = new MyMdiLayoutManager();
```

## Drag preview and overlays

Drag previews and dock adorners are rendered inside the managed layer:

```csharp
DockSettings.ShowDockablePreviewOnDrag = true;
DockSettings.DragPreviewOpacity = 0.7;
```

When dragging a managed floating window, the window itself moves so no preview overlay is shown.

## Troubleshooting

- Floating windows do not appear: verify `DockSettings.UseManagedWindows` is `true` and `EnableManagedWindowLayer` is enabled.
- Custom templates: ensure `PART_ManagedWindowLayer` exists in the `DockControl` template.
- Custom host window factory: return `ManagedHostWindow` when managed mode is enabled.
46 changes: 46 additions & 0 deletions docfx/articles/dock-managed-windows-reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Managed Windows Reference

This reference summarizes the main settings and types involved in managed window hosting.

## Settings

| Setting | Description |
| --- | --- |
| `DockSettings.UseManagedWindows` | Use in-app managed windows for floating dock windows. |
| `DockSettings.EnableWindowMagnetism` | Snap managed windows to nearby windows when dragging. |
| `DockSettings.WindowMagnetDistance` | Snap distance in pixels for managed window magnetism. |
| `DockSettings.BringWindowsToFrontOnDrag` | Activate managed windows when dragging begins. |
| `DockSettings.ShowDockablePreviewOnDrag` | Render dockable content inside drag previews. |
| `DockSettings.DragPreviewOpacity` | Opacity for drag previews in managed mode. |
| `DockSettings.UseOwnerForFloatingWindows` | Applies to native windows only. |

## App builder and options

| API | Description |
| --- | --- |
| `AppBuilderExtensions.UseManagedWindows` | Enables managed windows in the app builder. |
| `DockSettingsOptions.UseManagedWindows` | Nullable option used by `WithDockSettings`. |

## DockControl integration

| API | Description |
| --- | --- |
| `DockControl.EnableManagedWindowLayer` | Enables registration and display of the managed layer. |
| `DockControl.HostWindowFactory` | Override host window creation. Return `ManagedHostWindow` in managed mode. |

## Managed window types

| Type | Description |
| --- | --- |
| `ManagedHostWindow` | `IHostWindow` implementation that inserts a managed window into the layer. |
| `ManagedWindowLayer` | `TemplatedControl` that hosts managed windows and overlays. |
| `ManagedWindowDock` | Dock used to track managed floating windows. |
| `ManagedDockWindowDocument` | `IMdiDocument` wrapper around `IDockWindow` with `MdiBounds`, `MdiState`, and `MdiZIndex`. |

## MDI integration

| Type | Description |
| --- | --- |
| `MdiDocumentWindow` | Control that renders managed floating windows. |
| `IMdiLayoutManager` | Strategy for arranging MDI windows. |
| `ClassicMdiLayoutManager` | Default managed window layout manager. |
1 change: 1 addition & 0 deletions docfx/articles/dock-mdi.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@ For details on the built-in layout helpers and defaults see

- The document header contains a drag handle that starts docking operations when you drag it outside the MDI surface.
- When a document is maximized the stored bounds remain unchanged so restore returns to the previous size.
- Managed floating windows reuse `MdiDocumentWindow` inside `ManagedWindowLayer` when `DockSettings.UseManagedWindows` is enabled. See the [Managed windows guide](dock-managed-windows-guide.md).

For an overview of all guides see the [documentation index](README.md).
2 changes: 2 additions & 0 deletions docfx/articles/dock-pinned-window.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ DockSettings.UsePinnedDockWindow = true;

When enabled the `PinnedDockControl` places the preview content inside a lightweight `PinnedDockWindow`. The window follows the host layout and closes automatically when the tool is hidden.

In managed window mode (`DockSettings.UseManagedWindows = true`), pinned windows render inside `ManagedWindowLayer` instead of a native window.

## Alignment and orientation

`PinnedDockControl` exposes `PinnedDockAlignment` to control which edge the pinned preview occupies. The default templates bind it to the owning `ToolDock.Alignment`, but you can override it when building custom templates.
Expand Down
6 changes: 6 additions & 0 deletions docfx/articles/dock-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ The default value is `0.25`.

`DockSettings.UsePinnedDockWindow` shows auto-hidden dockables inside a floating window instead of sliding panels. See [Pinned Dock Window](dock-pinned-window.md) for details.

## Managed windows

`DockSettings.UseManagedWindows` hosts floating windows inside the main window using the managed window layer. This affects only floating docks; the main window remains native. See [Managed windows guide](dock-managed-windows-guide.md) for details.

## Window magnetism

`DockSettings.EnableWindowMagnetism` toggles snapping of floating windows. The snap distance
Expand Down Expand Up @@ -173,6 +177,7 @@ AppBuilder.Configure<App>()
.UsePlatformDetect()
.UseFloatingDockAdorner()
.UseOwnerForFloatingWindows()
.UseManagedWindows()
.EnableWindowMagnetism()
.SetWindowMagnetDistance(16)
.BringWindowsToFrontOnDrag()
Expand All @@ -194,6 +199,7 @@ AppBuilder.Configure<App>()
| `MinimumVerticalDragDistance` | `DockSettings.MinimumVerticalDragDistance` | Vertical drag threshold. |
| `UseFloatingDockAdorner` | `DockSettings.UseFloatingDockAdorner` | Floating adorner window. |
| `UsePinnedDockWindow` | `DockSettings.UsePinnedDockWindow` | Floating pinned dock window. |
| `UseManagedWindows` | `DockSettings.UseManagedWindows` | Managed floating windows. |
| `UseOwnerForFloatingWindows` | `DockSettings.UseOwnerForFloatingWindows` | Assign owners to floating windows. |
| `EnableWindowMagnetism` | `DockSettings.EnableWindowMagnetism` | Snap floating windows. |
| `WindowMagnetDistance` | `DockSettings.WindowMagnetDistance` | Snap distance in pixels. |
Expand Down
Loading