In This Article

StandaloneToolBar Class

Represents a standalone toolbar control that can host bar controls, and is a replacement for a native ToolBar.

[TemplatePart(Name = "PART_OverflowPanel", Type = typeof(StandaloneToolBarOverflowPanel))]
public class StandaloneToolBar : ItemsControl, IOverflowingItemsControl, IRootBarControl, IOrientedElement
Inheritance:
object Visual UIElement FrameworkElement Control ItemsControl object
Implements:
IOverflowingItemsControl IRootBarControl IOrientedElement

Constructors

StandaloneToolBar()

Initializes an instance of the class.

public StandaloneToolBar()

Properties

CornerRadius

The corner radius of the control's border.

public CornerRadius CornerRadius { get; set; }

Property Value

CornerRadius

HasShadow

Indicates whether the toolbar has a shadow.

public bool HasShadow { get; set; }

Property Value

bool:

true if the toolbar has a shadow; otherwise, false.

IsOverflowed

Indicates whether the toolbar is overflowed, which is when it isn't large enough to display all items.

public bool IsOverflowed { get; }

Property Value

bool:

true if the toolbar is overflowed; otherwise, false.

ItemContainerTemplateSelector

The ItemContainerTemplateSelector that creates UI controls for bar control view models.

public ItemContainerTemplateSelector? ItemContainerTemplateSelector { get; set; }

Property Value

ItemContainerTemplateSelector

ItemSpacing

The amount of spacing between items.

public double ItemSpacing { get; set; }

Property Value

double:

The default value is 1.

Orientation

The orientation of the element.

public Orientation Orientation { get; set; }

Property Value

Orientation

OverflowButtonKeyTipText

The Overflow button's key tip text.

[Localizability(LocalizationCategory.Label)]
public string? OverflowButtonKeyTipText { get; set; }

Property Value

string

OverflowButtonToolTip

The tooltip for the overflow button.

public object? OverflowButtonToolTip { get; set; }

Property Value

object

UserInterfaceDensity

A UserInterfaceDensity that indicates how compact or spacious the UI should appear.

public UserInterfaceDensity UserInterfaceDensity { get; set; }

Property Value

UserInterfaceDensity:

The default value is Compact.

Methods

ClearContainerForItemOverride(DependencyObject, object)

When overridden in a derived class, undoes the effects of the PrepareContainerForItemOverride(DependencyObject, object) method.

protected override void ClearContainerForItemOverride(DependencyObject element, object item)
Parameter Type Description
element DependencyObject

The container element.

item object

The item.

GetContainerForItemOverride()

Creates or identifies the element that is used to display the given item.

protected override DependencyObject GetContainerForItemOverride()

Returns

DependencyObject:

The element that is used to display the given item.

IsItemItsOwnContainerOverride(object)

Determines if the specified item is (or is eligible to be) its own container.

protected override bool IsItemItsOwnContainerOverride(object item)
Parameter Type Description
item object

The item to check.

Returns

bool:

true if the item is (or is eligible to be) its own container; otherwise, false.

OnApplyTemplate()

When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate().

public override void OnApplyTemplate()

OnContextMenuOpening(ContextMenuEventArgs)

Invoked whenever an unhandled ContextMenuOpening routed event reaches this class in its route. Implement this method to add class handling for this event.

protected override void OnContextMenuOpening(ContextMenuEventArgs e)
Parameter Type Description
e ContextMenuEventArgs

The RoutedEventArgs that contains the event data.

OnCreateAutomationPeer()

Returns class-specific AutomationPeer implementations for the Windows Presentation Foundation (WPF) infrastructure.

protected override AutomationPeer OnCreateAutomationPeer()

Returns

AutomationPeer:

The type-specific AutomationPeer implementation.

OnMenuOpening(BarMenuEventArgs)

Occurs before a generated menu is opened, allowing for customization.

protected virtual void OnMenuOpening(BarMenuEventArgs e)
Parameter Type Description
e BarMenuEventArgs

The event data.

OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs)

Invoked when an unhandled System.Windows.Input.Keyboard.PreviewGotKeyboardFocus attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

protected override void OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
Parameter Type Description
e KeyboardFocusChangedEventArgs

The KeyboardFocusChangedEventArgs that contains the event data.

OpenContextMenuForElement(DependencyObject?)

Opens a programmatically-generated context menu for the specified object or one of its ancestor elements as appropriate.

public bool OpenContextMenuForElement(DependencyObject? sourceObj)
Parameter Type Description
sourceObj DependencyObject

The source System.Windows.DependencyObject to examine.

Returns

bool:

true if a menu was opened; otherwise, false.

PrepareContainerForItemOverride(DependencyObject, object)

Prepares the specified element to display the specified item.

protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
Parameter Type Description
element DependencyObject

Element used to display the specified item.

item object

Specified item.

ToString()

Returns the string representation of this object.

public override string ToString()

Returns

string:

The string representation of this object.

Events

MenuOpening

Occurs before a generated menu is opened, allowing for customization.

public event EventHandler<BarMenuEventArgs> MenuOpening

Event Type

EventHandler<BarMenuEventArgs>

Fields

CornerRadiusProperty

Defines the CornerRadius property.

public static readonly DependencyProperty CornerRadiusProperty

HasShadowProperty

Defines the HasShadow property.

public static readonly DependencyProperty HasShadowProperty

IsOverflowedProperty

Defines the IsOverflowed property.

public static readonly DependencyProperty IsOverflowedProperty

ItemContainerTemplateSelectorProperty

Defines the ItemContainerTemplateSelector property.

public static readonly DependencyProperty ItemContainerTemplateSelectorProperty

ItemSpacingProperty

Defines the ItemSpacing property.

public static readonly DependencyProperty ItemSpacingProperty

MenuOpeningEvent

Defines the MenuOpening routed event.

public static readonly RoutedEvent MenuOpeningEvent

OrientationProperty

Defines the Orientation property.

public static readonly DependencyProperty OrientationProperty

OverflowButtonKeyTipTextProperty

Defines the OverflowButtonKeyTipText property.

public static readonly DependencyProperty OverflowButtonKeyTipTextProperty

OverflowButtonToolTipProperty

Defines the OverflowButtonToolTip property.

public static readonly DependencyProperty OverflowButtonToolTipProperty

UserInterfaceDensityProperty

Defines the UserInterfaceDensity property.

public static readonly DependencyProperty UserInterfaceDensityProperty

Extension Methods