how to create a docking(floating) toolbar in wpf

13,798

Solution 1

I recommend you look at third party control libraries for this. Syncfusion is a commercial product that contains a dock manager component in their essential tools collection. It's not really like office 2k3 though (more like Visual Studio). There is also one on codeplex and I'm sure there are several others at various price ranges.

For the actual undocking of toolbars from the main toolbar area I believe the standard WPF toolbar controls already supports this. At least you can move them around within a toolbar tray.

Solution 2

For the plain docking you would use the DockPanel:

<DockPanel>
    <Button DockPanel.Dock="Top">This would be a toolbar at the top</Button>
    <Butto>This would the main work area</Button>
</DockPanel>

<DockPanel>
    <Button DockPanel.Dock="Left">This would be a toolbar at the left</Button>
    <Button>This would the main work area</Button>
</DockPanel>

Instead of Button you would of course use the classes that are more apropriate for your needs.

However when you needs a windowing system with floating windows you will have to revert to a 3rd party library because it WPF does not have it and it would be pretty hard to roll your own. Here are some libs:

If all you really need is the docking floating toolbar (and no other windows) you can use the ToolBar class in conjunction with the ToolBarTray class. But you will need to write code to detect the drag, remove the ToolBar element from the visual tree, and then add it as a root visual to your own Window or HwndSource. You'll then need to detect when the window is over your drop zone to move the ToolBar from the window to the main window's visual tree and close the other window.

Share:
13,798
ashish semwal
Author by

ashish semwal

Hi all, I am software engineer in India.

Updated on June 05, 2022

Comments

  • ashish semwal
    ashish semwal almost 2 years

    I am new to wpf. I have to create a floating ToolBar in wpf like the ms - office 2003 toolbar. So that I can place it anywhere top - bottom, left- right as same as it was in office 2003.

    Please help me .......................