AdvToolBar Image

AdvToolBar Image 1

AdvToolBar Image

AdvToolBar Image

AdvToolBar Image

AdvToolBar Image

AdvToolBar is an advanced tool bar with all the features and functions of the standard tool bar plus the following:

  • 6 distinct visual styles built-in
  • Ability to stretch an item to fill the available space.
  • Ability to hide the overflow button in not used.
  • Ability to add a custom element to the overflow drop down.

The way to cause an element (or elements) to fill available space is to set its HorizontalAlignment (or VerticalAlignment for vertically oriented tool bars) to Stretch.

Use AdvToolBar.CustomObject and AdvToolBar.CustomObjectTemplate to define the custom content for the overflow panel.

Public Interface

AdvToolBar inherits from System.Windows.Controls.ToolBar and works the same way, nothing has been taken away or removed.

Properties

The following properties are defined by AdvToolBar:

AlwaysShowOverflowButton – Get or set whether the overflow button should be shown when there is no content for the overflow panel. The default value is false.

CornerRadius – Get or set the corner radius for the tool bar’s border.

CustomObject – Get or set an object which is added to the content of the overflow panel when opened. In the default template, this object is rendered just below the overflow items, if there are any.

CustomObjectTemplate – Get or set an optional DataTemplate to use for displaying the custom object.

Customizing Visual Appearance

The visual appearance of the tool bar can be changed in a number of ways. Of course, the standard WPF practices for customizing controls are fully supported, including support for custom Styles and Templates.

Visual Style

The easiest way to change the visual appearance is via the attached dependency property VisualStyleManager.VisualStyle. VisualStyle is an enum with the following possible values:

  • Default
  • WindowsExplorer
  • Office2010Blue
  • Office2010Silver
  • Office2010Black
  • VisualStudio2010

VisualStyleManager.VisualStyle can be set on any element that is an ancestor of the tool bar. Setting visual style with visual style manager has the advantage in that it will also set visual style for all controls from the DevComponents.WPF.Controls namespace as well as inserting implicit style definitions for the common Microsoft controls to facilitate a consistent look-and-feel across the entire application.

Visual Style Resources

Many of the resources which define the stylized appearance of the property grid are specified via resource references. The keys for these resources are ComponentResourceKeys. As a general rule, the resource key is defined as a static property on the control class which uses it.

Overriding or customizing a resource which is referenced via a ComponentResourceKey is as simple as defining a new resource and giving it the same key value. Most often, the new resource can be defined in Application or Window Resources. Occasionally, it will be necessary to define the key within the resources collection of the PropertyGrid itself. (This will be the case, especially, if a non-default value for PropertyGrid.VisualStyle has been set.)

Here is an example of a resource with a Key that is a ComponentResourceKey. (This resource defines the color of a Separator within the tool bar.):

<SolidColorBrush x:Key="{x:Static ctrls:AdvToolBar.SeparatorBrushKey}" Color="Gray" />

The resource keys available for this type of customization are generally discoverable as static properties on the class which uses the resource identified.

Related posts:

  1. WPF RadialMenu Quick Start Guide
  2. WPF Drag & Drop Quick Start
  3. PropertyGrid Quick Start Guide
  4. MobileRibbon Quick Start Guide, DotNetBar for WPF
  5. WPF Schedule Quick Start Guide