WPF - AvalonDock - Closing Document WPF - AvalonDock - Closing Document wpf wpf

WPF - AvalonDock - Closing Document


I actually find an unacceptable workaround.It is really twisted.

I only give that as reference. There should be a clean way to do it.

    // ************************************************************************    private void DockingManager_DocumentClosing(object sender, Xceed.Wpf.AvalonDock.DocumentClosingEventArgs e)    {        e.Document.CanClose = false;        DocumentModel documentModel = e.Document.Content as DocumentModel;        if (documentModel != null)        {            Dispatcher.BeginInvoke(new Action(() => this.Model.DocumentItems.Remove(documentModel)), DispatcherPriority.Background);        }    }


I have found that on a LayoutDocument or a LayoutAnchorablePane, applying both this setting works: CanClose="False" or CanFloat="False".

It removes the Close button.

<avalonDock:LayoutDocument Title="Board"                           ContentId="Board"                           CanClose="False"                           CanFloat="False"></avalonDock:LayoutDocument>


Register for IsVisibleChanged.

void layoutFPR_Hidden(object sender, EventArgs e){    LayoutAnchorable window = (LayoutAnchorable)sender;    YourClass content = window.Content as YourClass;    // Close the object    content = null;    ((LayoutAnchorable)sender).Close();}