What is the exact difference between ToolBarPanel and ToolBarTray in wpf?

30,322

Here you are

The ToolBar uses a ToolBarPanel and a ToolBarOverflowPanel in its ControlTemplate. The ToolBarPanel is responsible for the layout of the items on the toolbar. The ToolBarOverflowPanel is responsible for the layout of the items that do not fit on the ToolBar. For an example of a ControlTemplate for a ToolBar, see

https://docs.microsoft.com/en-us/dotnet/desktop/wpf/controls/toolbar-overview?view=netframeworkdesktop-4.8

ToolBarPanel Class

XAML

 <ToolBarTray Background="White">
      <ToolBar Band="1" BandIndex="1">
        <Button>
          <Image Source="toolbargraphics\cut.bmp" />
        </Button>
        <Button>
          <Image Source="toolbargraphics\copy.bmp" />
        </Button>
        <Button>
          <Image Source="toolbargraphics\paste.bmp" />
        </Button>
        <Button>
          <Image Source="toolbargraphics\undo.bmp" />
        </Button>
        <Button>
          <Image Source="toolbargraphics\redo.bmp" />
        </Button>
        <Button>
          <Image Source="toolbargraphics\paint.bmp" />
        </Button>
        <Button>
          <Image Source="toolbargraphics\spell.bmp" />
        </Button>
        <Separator/>
        <Button ToolBar.OverflowMode="Always">
          <Image Source="toolbargraphics\save.bmp" />
        </Button>
        <Button ToolBar.OverflowMode="Always">
          <Image Source="toolbargraphics\open.bmp" />
        </Button>
        <Button ToolBar.OverflowMode="Always">
          <Image Source="toolbargraphics\print.bmp" />
        </Button>
        <Button ToolBar.OverflowMode="Always">
          <Image Source="toolbargraphics\preview.bmp" />
        </Button>
      </ToolBar>
    </ToolBarTray>
Share:
30,322

Related videos on Youtube

UFO
Author by

UFO

Updated on September 10, 2020

Comments

  • UFO
    UFO over 3 years

    What is the exact difference between ToolBarPanel and ToolBarTray in WPF?

    • Admin
      Admin over 10 years
      Did you read the MSDN documentation? msdn.microsoft.com/en-us/library/ms752063.aspx. Essentially, you can put a ToolBar into a ToolBarTray, whereas a ToolBarPanel is used as a part of the ToolBar control template.
    • Thomas
      Thomas over 8 years
      @elgonzo that link is now broken. Is there another?
    • Admin
      Admin over 8 years
      @Thomas, the document is still there. When visiting the page, notice the "Other versions" link (it is a drop-down box) underneath the heading "This topic is no longer available". Choose one of the older framework versions to see the document (apparently, MS' documentation system screwed up and failed to import this page for the documentation of "newer" .NET versions). Or just follow this link... :)