Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create a docking(floating) toolbar in wpf

Tags:

wpf

toolbar

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 .......................

like image 384
ashish semwal Avatar asked Feb 18 '26 23:02

ashish semwal


1 Answers

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:

  • SandDock (not free)
  • WPF Docking lib
  • WPF Docking Control (not free)
  • Avalon Dock
  • Docking & MDI for WPF (not free)
  • Docking Manager (not free)

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.

like image 122
bitbonk Avatar answered Feb 21 '26 13:02

bitbonk