Reputation: 26398
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>
Upvotes: 1
Views: 1930
Reputation: 909
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.
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
Upvotes: 1