AvalonDock provides a system that allow developers to create customizable layouts using a window docking system similar to what is found in many popular integrated development environements (IDEs).
The DockingManager class is the core control of AvalonDock. Its Layout property contains the layout composition that is represented by the classes in the Xceed.Wpf.AvalonDock.Layout namespace. The class arranges the panes it contains and also handles auto-hide panes and floating windows (panes in turn contain, directly or indirectly, the two types of "content" elements, namely, LayoutAnchorable and LayoutDocument elements). The DockingManager class also handles saving and restoring layouts.
The View is represented by the classes contained in the Xceed.Wpf.AvalonDock.Controls namespace; these classes are a set of stylizable controls that show the user controls. The names of the view controls typically end with "Control" (for example, LayoutAnchorableControl is the view control, whereas LayoutAnchorable is the model element).
The DockingManager uses various classes (such as the LayoutItem and its derived classes) to perform the role of the ViewModel, preparing the model to be consumed by the view.
There is one and only one logical tree, which has the DockingManager as its root. Even if a control is placed in a different window (i.e., autohidden windows or floating windows), it always belong to the same logical tree below the DockingManager.
Example
The following example shows how to set up various panes in a DockingManager.
<local:DemoViewx:Class="LiveExplorer.Samples.AvalonDock.Views.AvalonDockView"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="clr-namespace:LiveExplorer"xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"xmlns:s="clr-namespace:System;assembly=mscorlib"><Grid><Grid.RowDefinitions><RowDefinitionHeight="Auto"/><RowDefinitionHeight="*"/></Grid.RowDefinitions><StackPanelOrientation="Horizontal"Margin="0,0,0,10"><TextBlockText="Theme:"Margin="0,0,10,0"VerticalAlignment="Center"/><ComboBoxx:Name="_themeCombo"SelectedIndex="0"Width="200"><ComboBoxItemContent="Generic"/><ComboBoxItemContent="Aero"><ComboBoxItem.Tag><xcad:AeroTheme/></ComboBoxItem.Tag></ComboBoxItem><ComboBoxItemContent="VS2010"><ComboBoxItem.Tag><xcad:VS2010Theme/></ComboBoxItem.Tag></ComboBoxItem><ComboBoxItemContent="Metro"><ComboBoxItem.Tag><xcad:MetroTheme/></ComboBoxItem.Tag></ComboBoxItem></ComboBox></StackPanel><xcad:DockingManagerGrid.Row="1"MaxHeight="425"AllowMixedOrientation="True"BorderBrush="Black"BorderThickness="1"Theme="{Binding ElementName=_themeCombo, Path=SelectedItem.Tag}"><xcad:DockingManager.DocumentHeaderTemplate><DataTemplate><StackPanelOrientation="Horizontal"><ImageSource="{Binding IconSource}"Margin="0,0,4,0"/><TextBlockText="{Binding Title}"/></StackPanel></DataTemplate></xcad:DockingManager.DocumentHeaderTemplate><xcad:LayoutRootx:Name="_layoutRoot"><xcad:LayoutPanelOrientation="Horizontal"><xcad:LayoutAnchorablePaneDockWidth="200"><xcad:LayoutAnchorableContentId="properties"Title="Properties"CanHide="False"CanClose="False"AutoHideWidth="240"IconSource="../Images/property-blue.png"><xctk:PropertyGridNameColumnWidth="110"SelectedObject="{Binding ElementName=_layoutRoot, Path=LastFocusedDocument.Content}"/></xcad:LayoutAnchorable></xcad:LayoutAnchorablePane><xcad:LayoutDocumentPaneGroup><xcad:LayoutDocumentPane><xcad:LayoutDocumentContentId="document1"Title="Document 1"IconSource="../Images/document.png"><ButtonContent="Document 1 Content"HorizontalAlignment="Center"VerticalAlignment="Center"/></xcad:LayoutDocument><xcad:LayoutDocumentContentId="document2"Title="Document 2"IconSource="../Images/document.png"><TextBoxText="Document 2 Content"AcceptsReturn="True"/></xcad:LayoutDocument></xcad:LayoutDocumentPane></xcad:LayoutDocumentPaneGroup>
<xcad:LayoutAnchorablePaneGroupDockWidth="125"><xcad:LayoutAnchorablePane><xcad:LayoutAnchorableContentId="alarms"Title="Alarms"IconSource="../Images/alarm-clock-blue.png"><ListBox><s:String>Alarm 1</s:String><s:String>Alarm 2</s:String><s:String>Alarm 3</s:String></ListBox></xcad:LayoutAnchorable><xcad:LayoutAnchorableContentId="journal"Title="Journal"><RichTextBox><FlowDocument><ParagraphFontSize="14"FontFamily="Segoe">
This is the content of the Journal Pane.
<LineBreak/>
A
<Bold>RichTextBox</Bold> has been added here
</Paragraph></FlowDocument></RichTextBox></xcad:LayoutAnchorable></xcad:LayoutAnchorablePane></xcad:LayoutAnchorablePaneGroup></xcad:LayoutPanel><xcad:LayoutRoot.LeftSide><xcad:LayoutAnchorSide><xcad:LayoutAnchorGroup><xcad:LayoutAnchorableTitle="Agenda"ContentId="agenda"IconSource="../Images/address-book-open.png"><TextBlockText="Agenda Content"Margin="10"FontSize="18"FontWeight="Black"TextWrapping="Wrap"/></xcad:LayoutAnchorable><xcad:LayoutAnchorableTitle="Contacts"ContentId="contacts"IconSource="../Images/address-book--pencil.png"><TextBlockText="Contacts Content"Margin="10"FontSize="18"FontWeight="Black"TextWrapping="Wrap"/></xcad:LayoutAnchorable></xcad:LayoutAnchorGroup></xcad:LayoutAnchorSide></xcad:LayoutRoot.LeftSide></xcad:LayoutRoot></xcad:DockingManager></Grid></local:DemoView>
Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2