Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

wpf

toolbar

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

like image 228
UFO Avatar asked Oct 29 '13 16:10

UFO


People also ask

What is ToolBar in WPF?

The ToolBar control takes its name from the bar-like arrangement of buttons or other controls into a single row or column. WPF ToolBar controls provide an overflow mechanism which places any items that do not fit naturally within a size-constrained ToolBar into a special overflow area.

What is a StackPanel WPF?

A StackPanel allows you to stack elements in a specified direction. By using properties that are defined on StackPanel, content can flow both vertically, which is the default setting, or horizontally.


1 Answers

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>
like image 102
Friend Avatar answered Sep 21 '22 05:09

Friend