Quantcast
Channel: AvalonDock
Viewing all articles
Browse latest Browse all 2690

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

$
0
0
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>(
                    this,
                    DropAreaType.DockingManager));

                foreach (var areaHost in this.FindVisualChildren<LayoutAnchorablePaneControl>())
                {
                    if (areaHost.Model.Descendents().Any())
                    {
                        _areas.Add(new DropArea<LayoutAnchorablePaneControl>(
                            areaHost,
                            DropAreaType.AnchorablePane));
                    }
                }
            }

            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>(
                    areaHost,
                    DropAreaType.DocumentPane));
            }

            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>(
                        areaHost,
                        DropAreaType.DocumentPaneGroup));
                }
            }

            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.CanExecuteDockAsDocumentCommandprotected virtuaL instead of private
    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 !

Viewing all articles
Browse latest Browse all 2690

Trending Articles