Skip to content

Repository files navigation

NuExt.Minimal.Mvvm.AvalonDock

NuExt.Minimal.Mvvm.AvalonDock integrates AvalonDock with NuExt.Minimal.Mvvm.Wpf, providing MVVM infrastructure for dockable documents and tool windows.

NuGet Ask DeepWiki Build License Downloads

Compatibility

  • WPF on .NET 8/9/10/11 and .NET Framework 4.8+
  • AvalonDock 5

Installation

Via NuGet:

dotnet add package NuExt.Minimal.Mvvm.AvalonDock

Or via Visual Studio:

  1. Go to Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution....
  2. Search for NuExt.Minimal.Mvvm.AvalonDock.
  3. Click Install.

Recommended companions

Usage

Attach the required services to an AvalonDock docking manager:

<avalonDock:DockingManager>
  <nx:Interaction.Behaviors>
    <nx:AvalonDockDocumentService x:Name="Documents" />
    <nx:AvalonDockToolWindowService x:Name="Tools" />
  </nx:Interaction.Behaviors>
</avalonDock:DockingManager>

The services are available to ViewModels as named services:

public IAsyncDocumentManagerService DocumentManagerService =>
    GetRequiredService<IAsyncDocumentManagerService>("Documents");

public IAsyncToolWindowManagerService ToolWindowManagerService =>
    GetRequiredService<IAsyncToolWindowManagerService>("Tools");

Tool windows

IToolWindow toolWindow = await ToolWindowManagerService.CreateToolWindowAsync(
    toolWindowType: nameof(PropertiesView),
    viewModelFactory: static () => new PropertiesViewModel(),
    parentViewModel: this,
    parameter: null,
    options: new ToolWindowOptions
    {
        Id = "Properties",
        Title = "Properties",
        Placement = ToolWindowPlacement.Left,
        CanFloat = false,
        CanDockAsTabbedDocument = false
    },
    cancellationToken: cancellationToken);

toolWindow.Show();

Tool windows are long-lived UI panels. Show() displays and activates a panel, while Hide() hides or collapses it without disposing its ViewModel. The tool window manager owns created ViewModels and disposes them during service cleanup.

A tool window can be retrieved by its identifier:

ToolWindowManagerService.FindToolWindowById("Properties")?.Show();

ToggleDockingManager

AvalonDockToolWindowService supports ToggleDockingManager:

<avalonDock:ToggleDockingManager>
  <nx:Interaction.Behaviors>
    <nx:AvalonDockDocumentService x:Name="Documents" />
    <nx:AvalonDockToolWindowService x:Name="Tools" />
  </nx:Interaction.Behaviors>
</avalonDock:ToggleDockingManager>

Tool windows managed by ToggleDockingManager must be created before the manager is loaded. Their initial side is configured through ToolWindowOptions.Placement.

Ecosystem

Contributing

Issues and PRs are welcome. Keep changes minimal and performance-conscious.

License

MIT. See LICENSE.

Contributors

Languages