Search code examples
wpftoolbar

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


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


Solution

  • 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://learn.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>