Skip to Main Content
Programming WPF, 2nd Edition
book

Programming WPF, 2nd Edition

by Chris Sells, Ian Griffiths
August 2007
Intermediate to advanced content levelIntermediate to advanced
864 pages
25h 52m
English
O'Reilly Media, Inc.
Content preview from Programming WPF, 2nd Edition

Toolbars

Most Windows applications offer toolbars as well as menus. Toolbars provide faster access for frequently used operations, because the user does not need to navigate through the menu system—the toolbar is always visible on-screen. Figure 5-28 shows a pair of typical toolbars.

Application with toolbars

Figure 5-28. Application with toolbars

WPF supports toolbars through the ToolBarTray and ToolBar controls. ToolBarTray provides a container into which you can add multiple ToolBar elements. Example 5-27 shows a simple example with two toolbars; this is the markup for the toolbars in Figure 5-28.

Example 5-27. ToolBarTray and ToolBar

<ToolBarTray>
  <ToolBar> <Button> <Canvas Width="16" Height="16" SnapsToDevicePixels="True"> <Polygon Stroke="Black" StrokeThickness="0.5" Points="2.5,1.5 9.5,1.5 12.5,4.5 12.5,15 2.5,15"> <Polygon.Fill> <LinearGradientBrush StartPoint="1,1" EndPoint="0.2,0.7"> <GradientStop Offset="0" Color="#AAA" /> <GradientStop Offset="1" Color="White" /> </LinearGradientBrush> </Polygon.Fill> </Polygon> <Polygon Stroke="Black" Fill="DarkGray" StrokeThickness="0.5" StrokeLineJoin="Bevel" Points="9.5,1.5 9.5,4.5 12.5,4.5" /> </Canvas> </Button> <Button> <Canvas Width="16" Height="16" > <Polygon Stroke="Black" StrokeThickness="0.5" Fill="Khaki" SnapsToDevicePixels="True" Points="0.5,14.5 0.5,4.5 1.5,3.5 6.5,3.5 8.5,5.5 12.5,5.5 12.5,14.5" /> <Polygon Stroke="Black" SnapsToDevicePixels="True" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming C#, 4th Edition

Programming C#, 4th Edition

Jesse Liberty
Programming C# 10

Programming C# 10

Ian Griffiths

Publisher Resources

ISBN: 9780596510374Supplemental ContentErrata Page