Dock

Host Window Locators

Dock can display floating windows when a dockable is detached from the main layout. IFactory uses host window locators to supply the platform window objects that wrap these floating docks. This guide explains how the HostWindowLocator and DefaultHostWindowLocator properties work and shows typical usage patterns.

Why locators are required

The HostAdapter component bridges an IDockWindow with an IHostWindow implementation. When a dockable is floated the adapter queries the factory using GetHostWindow to obtain the actual host window instance. Without a locator the factory cannot create platform windows and floating docks will fail to appear.

Registering locators also allows you to integrate dependency injection or apply platform specific customisation when new windows are created.

Providing host windows

HostWindowLocator is a dictionary mapping string keys to functions that return an IHostWindow. When GetHostWindow is called with a key, the factory invokes the matching function. A common setup registers a default entry for IDockWindow:

HostWindowLocator = new Dictionary<string, Func<IHostWindow?>>
{
    [nameof(IDockWindow)] = () => new HostWindow()
};

When different window styles are required, add additional keys and choose which one to pass to GetHostWindow.

Fallback locator

If no entry matches the provided key, GetHostWindow calls DefaultHostWindowLocator. Set this delegate to return a generic host window when the dictionary does not contain a specific mapping:

DefaultHostWindowLocator = () => new HostWindow();

The fallback ensures floating windows still open even if a key is missing.

  1. Populate HostWindowLocator inside InitLayout or during application startup.
  2. Provide a DefaultHostWindowLocator so floating windows always have a host.
  3. Call GetHostWindow(id) from custom code or rely on HostAdapter, which invokes it automatically when presenting windows.

Using locators in this way keeps window creation centralized in the factory and makes it easy to customise the hosting behaviour.

For further details on floating windows see the Floating windows guide.