Question

How can I bind to a model such that Avalon Dock 2 treats it as a floating pane?

In basic terms I want to open a window that can be docked and ideally have a MVVM solution. But the furthest I've been able to get to is to get anchorables and no way I can see to entice the docking manager to make them floating.

<xcad:DockingManager AnchorablesSource="{Binding Tools}">

    <xcad:DockingManager.LayoutItemContainerStyle>
        <Style TargetType="{x:Type xcad:LayoutItem}">
            <Setter Property="Title" Value="{Binding Model.Title}"/>    
        </Style>
    </xcad:DockingManager.LayoutItemContainerStyle>

    <xcad:DockingManager.LayoutItemTemplate>
        <DataTemplate>
            <ContentControl cal:View.Model="{Binding . }" IsTabStop="False" />
        </DataTemplate>
    </xcad:DockingManager.LayoutItemTemplate>

</xcad:DockingManager>
Was it helpful?

Solution

I have not done what you're suggesting with the floating windows, but I have managed to integrate Caliburn.Micro with AvalonDock. You'll need a couple of examples to help you and documentation.

  1. Download AvalonDock Source Code
  2. Download Gemini Source Code (Mash up of Caliburn.Micro and AvalonDock).

In short, use the LayoutInitializer in conjuction with a property on your ToolViewModelBase to indicate that the anchorable should be opened as floating.

<avalonDock:DockingManager.LayoutUpdateStrategy>
  <local:LayoutInitializer/>
</avalonDock:DockingManager.LayoutUpdateStrategy>

The AvalonDock source code of interest is below and you'll find equivalents in Gemini.

.\Version2.0\AvalonDock.MVVMTestApp\ToolViewModel.cs

.\Version2.0\AvalonDock.MVVMTestApp\LayoutInitializer.cs

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top