Exemplo n.º 1
0
        /// <summary>
        /// Cleanly close a visible Document.
        /// </summary>
        /// <param name="dockingManager">The Root item DockingManager.</param>
        /// <param name="content">Either a View, ViewModel or <see cref="Xceed.Wpf.AvalonDock.Layout.LayoutDocument"/>
        /// contained in the layout of the DockingManager as a Document.</param>
        /// <returns>True is successfully closed, otherwise false.</returns>
        public static bool CloseDocument(this DockingManager dockingManager, object content)
        {
            if (dockingManager == null)
            {
                throw new ArgumentNullException(nameof(dockingManager));
            }
            if (content == null)
            {
                return(true);
            }
            LayoutDocument document = dockingManager.FindDocument(content);
            LayoutItem     item     = dockingManager.GetLayoutItemFromModel(document);

            if (item != null)
            {
                item.CloseCommand.Execute(null);
            }
            if (document != null &&
                dockingManager.GetAllDocuments().Contains(document))
            {
                // This is where you would end up when cancelling closing a document.
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        public static bool FloatDocument(this DockingManager dockingManager, object content)
        {
            if (dockingManager == null)
            {
                throw new ArgumentNullException(nameof(dockingManager));
            }
            LayoutDocument document = dockingManager.FindDocument(content);
            LayoutItem     item     = dockingManager.GetLayoutItemFromModel(document);

            if (item != null && !document.IsFloating)
            {
                item.FloatCommand.Execute(true);
            }
            return(document.IsFloating);
        }