Click here to Skip to main content
15,894,825 members
Articles / Desktop Programming / WPF

WPF Docking Library

Rate me:
Please Sign up or sign in to vote.
4.78/5 (85 votes)
17 Jul 2007CPOL3 min read 1.1M   24.4K   317  
A WPF library to easily integrate Windows docking features in applications like VS
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DockingLibrary
{
    class FloatingWindowHostedPane : DockablePane
    {
        public readonly DockablePane ReferencedPane;
        FloatingWindow _floatingWindow;

        public FloatingWindowHostedPane(FloatingWindow floatingWindow, DockablePane referencedPane) : base(referencedPane.DockManager)
        {
            ReferencedPane = referencedPane;
            _floatingWindow = floatingWindow;

            DockableContent lastSelectedContent = ReferencedPane.ActiveContent;

            ChangeState(ReferencedPane.State);
            //ReferencedPane.Hide();

            //DockManager = ReferencedPane.DockManager;
            foreach (DockableContent content in ReferencedPane.Contents)
            {
                ReferencedPane.Hide(content);
                Add(content);
                Show(content);
                content.SetContainerPane(ReferencedPane);
            }

            ActiveContent = lastSelectedContent;
            ShowHeader = false;

        }

        

        public override void Remove(DockableContent content)
        {
            ReferencedPane.Remove(content);
            base.Remove(content);
        }

        protected override void OnDockingMenu(object sender, EventArgs e)
        {
            if (sender == menuFloatingWindow)
            {
                ReferencedPane.ChangeState(PaneState.FloatingWindow);
                ChangeState(ReferencedPane.State);
            }

            if (sender == menuDockedWindow)
            {
                ReferencedPane.ChangeState(PaneState.DockableWindow);
                ChangeState(ReferencedPane.State);
            }

            if (sender == menuTabbedDocument || sender == menuClose || sender == menuAutoHide)
            {
                foreach (DockableContent content in Contents)
                    content.SetContainerPane(ReferencedPane);

                Close();

                _floatingWindow.Close();
            }

            if (sender == menuTabbedDocument)
                ReferencedPane.TabbedDocument();
            if (sender == menuClose)
                ReferencedPane.Close();
            if (sender == menuAutoHide)
            {
                ReferencedPane.Show();
                ReferencedPane.AutoHide();
            }
        }


        //protected override void DragContent(DockableContent contentToDrag, Point startDragPoint, Point offset)
        //{
        //    Remove(contentToDrag);
        //    DockablePane pane = new DockablePane();
        //    pane = new DockablePane();
        //    pane.DockManager = DockManager;
        //    pane.Add(contentToDrag);
        //    pane.Show();
        //    DockManager.Add(pane);
        //    //DockManager.Add(contentToDrag);
        //    //pane.ChangeState(PaneState.DockableWindow);
        //    FloatingWindow wnd = new FloatingWindow(pane);
        //    pane.ChangeState(PaneState.DockableWindow);
        //    DockManager.Drag(wnd, startDragPoint, offset);            
        //}
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Systems Engineer
Italy Italy
I bought my first computer in Nov 1991, 21st and I started programming with QBasic under MSDOS.
Today my main interest is developping applications with .NET and HTML5 stack.

Comments and Discussions