Is it possible to prevent user from docking anchorables as tabbed documents?

Oct 2, 2012 at 9:08 AM

Hi! I'm using AvalonDock 2.0 in a non-MVVM application. I have this layout:

[ AnchorablePane ] [DocumentsPane] [ AnchorablePane ]

I don't want the user to dock any anchorable pane in the documents pane.

I tried to use a LayoutInitializer (ILayoutUpdateStrategy), but its methods are not being called. I thought they are called only when working with MVVM and "AnchorablesSource", "DocumentsSource".


Thanks a lot for your time and attention!

Oct 4, 2012 at 6:50 PM

I would be interested to have the same restriction. I havent spent time to see how it could (or if it can) be done.


Jan 4, 2013 at 8:45 PM
Edited Jan 5, 2013 at 7:54 AM

I am starting out with AvalonDock 2.0, using the MVVM TestApp with VS2010 theme (Dec 2012 release). The same restriction applies in my case (don't mix documents and anchorables = tools). I observe that: 

  • A tool docked in a document pane can be closed (like a document) and it is not created / used again... 
  • A tool docked in an anchorable pane is only hidden and the tool can be made visible and used later on.

This problem is similar to these posts

  • (August 2012)
     MVVM TestApp: if you close an anchorable item ('Tool Window 1') into the tabbed documents pane, you can close it for good.
    --- no reply 
  • (June 2012)
    --- use CanClose:
    You can add this attribute to the non-MVVM TestApp with 
    <avalonDock:LayoutAnchorable Title="Panel 1" CanClose="False">
    and it works ! However the layout in MVVM TestApp is done with LayoutItemTemplateSelector which doesn't accept CanClose. 
    Is there is a way to use LayoutAnchorable with LayoutItemTemplateSelector ?
  • (May 2012) 

This issue has been reoccuring and reported by several people, possibly over versions 1.3 and 2.0. 

Has anyone looked into this issue ?

Jan 14, 2014 at 9:06 PM
Edited Jan 14, 2014 at 9:07 PM
I have the same problem, here are the changes I did:
  1. Firstly, I don't want the overlay icons to appears on a document when I drag an anchorables floating window:
    Modify the method DockingManager.GetDropAreas to :
        IEnumerable<IDropArea> IOverlayWindowHost.GetDropAreas(LayoutFloatingWindowControl draggingWindow)
            if (_areas != null)
                return _areas;

            bool isDraggingDocuments = draggingWindow.Model is LayoutDocumentFloatingWindow;

            _areas = new List<IDropArea>();

            if (!isDraggingDocuments)
                _areas.Add(new DropArea<DockingManager>(

                foreach (var areaHost in this.FindVisualChildren<LayoutAnchorablePaneControl>())
                    if (areaHost.Model.Descendents().Any())
                        _areas.Add(new DropArea<LayoutAnchorablePaneControl>(

            if (draggingWindow is LayoutAnchorableFloatingWindowControl) // deny the possiblity to dock an anchorable with documents
                return _areas;

            foreach (var areaHost in this.FindVisualChildren<LayoutDocumentPaneControl>())
                _areas.Add(new DropArea<LayoutDocumentPaneControl>(

            foreach (var areaHost in this.FindVisualChildren<LayoutDocumentPaneGroupControl>())
                var documentGroupModel = areaHost.Model as LayoutDocumentPaneGroup;
                if (!documentGroupModel.Children.Any(c => c.IsVisible))
                    _areas.Add(new DropArea<LayoutDocumentPaneGroupControl>(

            return _areas;
  1. Secondly, I don't want the user to be able to use the Commands "Dock as Tabbed Document" which appears in both the DropDownMenu and the ContextMenu of the anchorables.
    a. Make the method LayoutItem.CanExecuteDockAsDocumentCommand protected virtuaL instead of private
        protected virtual bool CanExecuteDockAsDocumentCommand(object parameter)
            return LayoutElement != null && LayoutElement.FindParent<LayoutDocumentPane>() == null;
b. Implement it into LayoutAnchorableItem:
        protected override bool CanExecuteDockAsDocumentCommand(object parameter)
            return false;
I don't know if it's enough, but it seems to work for me, just try it !
Jan 15, 2014 at 7:02 AM
Awesome.. Just what I needed.

If any is interested, then to hide the context menu button, add this to the DockingManager:

        <MenuItem Header="{x:Static avalonDockProperties:Resources.Anchorable_Float}" 
                Command="{Binding Path=FloatCommand}"/>
        <MenuItem Header="{x:Static avalonDockProperties:Resources.Anchorable_Dock}" 
                Command="{Binding Path=DockCommand}"/>
        <MenuItem Header="{x:Static avalonDockProperties:Resources.Anchorable_AutoHide}" 
                Command="{Binding Path=AutoHideCommand}"/>
        <MenuItem Header="{x:Static avalonDockProperties:Resources.Anchorable_Hide}" 
                Command="{Binding Path=HideCommand}"
                Visibility="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"/>