title: Implementing a multidock window system (like blend, visual studio) in WPF
body: <p>How would you go about to implement a docking toolbox windowing system as seen in Expression Blend where you can dock toolbox windows in a lot of ways beneat each other, overlapping as tabs or as floating top level windows. My system should behave pretty much the same as in Expression Blend. Also the way I get visual cues where the toolbox window would dock when dragging is exactly what I need. </p>
  
  <p>There is just one exeception: In blend when dragging onto a toolbox window that is already top level (torn off) I can only dock it as a tab filling the whole window. I however need a system where there is no difference between a toolbox window and the main window. I need to be able to dock the windows beneath each other in a toolbox window just as in the main window.</p>
  
  <p><strong>Also note that due to an internal policy I can not use any open source or 3rd party library for this.</strong></p>
  
  <p>I'd be interested in how you would setup the general class design for something like this? I would like to stay as generic as possible so it can be used for lot of different scenarios.</p>
  
  <p>The dockeing behavior is as in the following picture. The center image shows the sensetive drag docking region. And the outer images where the window would snap:</p>
  
  <p><a href="http://img196.imageshack.us/img196/2450/dockingregions.png" rel="noreferrer">alt text http://img196.imageshack.us/img196/2450/dockingregions.png</a></p>
  
  <p>Generally I am facing to mayor problems here: How do I design the programming model (how are the docking configurations to be persisted in XAML) and how do I acutally implement the underlying functionality. My first tought would be that I'd like to habe a symbiosis of a DockPanel and a TabControl. Something in the lines of this:</p>
  
  <pre><code>&lt;DockTabControl&gt;
    &lt;DockTabItem Dock="FirstLeft"&gt;
      &lt;DockTabItem.Header&gt;
          &lt;TextBlock&gt;Tab 1&lt;/TextBlock&gt;
      &lt;/DockTabItem.Header&gt;
      &lt;!-- Tab 1 content --&gt;
    &lt;/DockTabItem&gt;
    &lt;DockTabItem Header="Tab 2" Dock="SecondLeft" DockMode="MergeWithPreviousToTabgroup"&gt;
      &lt;!-- Tab 2 content --&gt;
    &lt;/DockTabItem&gt;
    &lt;DockTabItem Header="Tab 3" Dock="FirstMiddle"&gt;
      &lt;!-- Tab 3 content --&gt;
    &lt;/DockTabItem&gt;
  &lt;/DockTabControl&gt;
  </code></pre>
  
  <p>Of course this doesn't make sense yet. Docking can't be defined that way and the windowing problem is not adressed here yet. But I like the idea of defining the docking and the tabgroups just by defining some properties on the DockTabItem. I really wouldn't want to introduce extra controls like TabGroups or similar. I like how the docking behavior in the DockPanel just by defining the order of the children and the Dock attached property. Of course my docking will be a bit more complex and behaves more like what the Grid does.</p>