In This Article

BarButton Class

Represents a standard button control, for use within a ribbon or toolbar.

public class BarButton : Button
Inheritance:
object Visual UIElement FrameworkElement Control ContentControl ButtonBase Button object
Derived:
BarToggleButton

Constructors

BarButton()

Initializes a new instance of the BarButton class.

public BarButton()

Properties

CanCloneToRibbonQuickAccessToolBar

Gets or sets whether the control can be cloned to the ribbon quick-access toolbar.

public bool CanCloneToRibbonQuickAccessToolBar { get; set; }

Property Value

bool:

true if the control can be cloned to the ribbon quick-access toolbar; otherwise, false. The default value is true.

HasLabel

Gets whether the control has a Label available.

public bool HasLabel { get; }

Property Value

bool:

true if the control has a Label available; otherwise, false. The default value is false.

ImageSourceResolved

Gets the resolved ImageSource for the image to use in the control's template.

public ImageSource ImageSourceResolved { get; }

Property Value

ImageSource:

The resolved ImageSource for the image to use in the control's template.

InputGestureText

Gets or sets the input gesture text to display in menu items and screen tips, which overrides any auto-generated input gesture text from the Command.

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

Property Value

string:

The input gesture text to display in menu items and screen tips.

IsInputGestureTextVisible

Gets or sets whether the input gesture text is allowed to be visible in the user interface.

public bool IsInputGestureTextVisible { get; set; }

Property Value

bool:

true if the input gesture text is allowed to be visible in the user interface; otherwise, false. The default value is true.

Key

Gets or sets a string that uniquely identifies the control.

[Localizability(LocalizationCategory.NeverLocalize)]
public string Key { get; set; }

Property Value

string:

A string that uniquely identifies the control.

KeyTipText

Gets or sets the key tip text used to access the control.

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

Property Value

string:

The key tip text used to access the control.

Label

Gets or sets the text label to display.

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

Property Value

string:

The text label to display.

LargeImageSource

Gets or sets the ImageSource for a large image, generally 32x32 size.

public ImageSource LargeImageSource { get; set; }

Property Value

ImageSource:

The ImageSource for a large image.

MediumImageSource

Gets or sets the ImageSource for a medium image, generally 24x24 size.

public ImageSource MediumImageSource { get; set; }

Property Value

ImageSource:

The ImageSource for a medium image.

ScreenTipFooter

Gets or sets the screen tip footer content.

public object ScreenTipFooter { get; set; }

Property Value

object:

The screen tip footer content.

ScreenTipHeader

Gets or sets the screen tip header content.

public object ScreenTipHeader { get; set; }

Property Value

object:

The screen tip header content.

SmallImageSource

Gets or sets the ImageSource for a small image, generally 16x16 size.

public ImageSource SmallImageSource { get; set; }

Property Value

ImageSource:

The ImageSource for a small image.

StaysOpenOnClick

Gets or sets whether the button doesn't try to restore focus to the main focus scope when clicked.

public bool StaysOpenOnClick { get; set; }

Property Value

bool:

true if the button doesn't try to restore focus to the main focus scope when clicked; otherwise, false. The default value is false.

Title

Gets or sets the string title, which can override the Label when displayed in screen tips and customization UI.

[Localizability(LocalizationCategory.Title)]
public string Title { get; set; }

Property Value

string:

The string title.

ToolBarItemCollapseBehavior

Gets or sets the ItemCollapseBehavior for the control when in a ribbon using Simplified layout mode.

public ItemCollapseBehavior ToolBarItemCollapseBehavior { get; set; }

Property Value

ItemCollapseBehavior:

The ItemCollapseBehavior for the control when in a ribbon using Simplified layout mode. The default value is Default.

ToolBarItemVariantBehavior

Gets or sets the ItemVariantBehavior for the control when in a toolbar, which also applies when in a ribbon using Simplified layout mode.

public ItemVariantBehavior ToolBarItemVariantBehavior { get; set; }

Property Value

ItemVariantBehavior:

The ItemVariantBehavior for the control when in a toolbar, which also applies when in a ribbon using Simplified layout mode. The default value is AlwaysSmall.

UserInterfaceDensity

Gets or sets a UserInterfaceDensity that indicates how compact or spacious the UI should appear.

public UserInterfaceDensity UserInterfaceDensity { get; set; }

Property Value

UserInterfaceDensity:

A UserInterfaceDensity that indicates how compact or spacious the UI should appear. The default value is Compact.

VariantSize

Gets or sets the VariantSize currently assigned to the control. This property should only be manually set when the control is standalone, and not hosted by a bar control.

public VariantSize VariantSize { get; set; }

Property Value

VariantSize:

The VariantSize currently assigned to the control.

Methods

OnApplyTemplate()

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

public override void OnApplyTemplate()

OnClick()

Called when a Button is clicked.

protected override void OnClick()

OnCreateAutomationPeer()

Creates an appropriate ButtonAutomationPeer for this control as part of the WPF infrastructure.

protected override AutomationPeer OnCreateAutomationPeer()

Returns

AutomationPeer:

A ButtonAutomationPeer for this control.

OnKeyTipInvoked(KeyTipInvokedEventArgs)

Occurs when the control's key tip is invoked.

protected virtual void OnKeyTipInvoked(KeyTipInvokedEventArgs e)
Parameter Type Description
e KeyTipInvokedEventArgs

The KeyTipInvokedEventArgs containing data related to this event.

OnMouseLeftButtonDown(MouseButtonEventArgs)

Provides class handling for the MouseLeftButtonDown routed event that occurs when the left mouse button is pressed while the mouse pointer is over this control.

protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
Parameter Type Description
e MouseButtonEventArgs

The event data.

OnToolTipOpening(ToolTipEventArgs)

Invoked whenever the ToolTipOpening routed event reaches this class in its route. Implement this method to add class handling for this event.

protected override void OnToolTipOpening(ToolTipEventArgs e)
Parameter Type Description
e ToolTipEventArgs

Provides data about the event.

ToString()

Returns the string representation of this object.

public override string ToString()

Returns

string:

The string representation of this object.

Fields

CanCloneToRibbonQuickAccessToolBarProperty

Identifies the CanCloneToRibbonQuickAccessToolBar dependency property. This field is read-only.

public static readonly DependencyProperty CanCloneToRibbonQuickAccessToolBarProperty

HasLabelProperty

Identifies the HasLabel dependency property. This field is read-only.

public static readonly DependencyProperty HasLabelProperty

ImageSourceResolvedProperty

Identifies the ImageSourceResolved dependency property. This field is read-only.

public static readonly DependencyProperty ImageSourceResolvedProperty

InputGestureTextProperty

Identifies the InputGestureText dependency property. This field is read-only.

public static readonly DependencyProperty InputGestureTextProperty

IsInputGestureTextVisibleProperty

Identifies the IsInputGestureTextVisible dependency property. This field is read-only.

public static readonly DependencyProperty IsInputGestureTextVisibleProperty

KeyProperty

Identifies the Key dependency property. This field is read-only.

public static readonly DependencyProperty KeyProperty

KeyTipTextProperty

Identifies the KeyTipText dependency property. This field is read-only.

public static readonly DependencyProperty KeyTipTextProperty

LabelProperty

Identifies the Label dependency property. This field is read-only.

public static readonly DependencyProperty LabelProperty

LargeImageSourceProperty

Identifies the LargeImageSource dependency property. This field is read-only.

public static readonly DependencyProperty LargeImageSourceProperty

MediumImageSourceProperty

Identifies the MediumImageSource dependency property. This field is read-only.

public static readonly DependencyProperty MediumImageSourceProperty

ScreenTipFooterProperty

Identifies the ScreenTipFooter dependency property. This field is read-only.

public static readonly DependencyProperty ScreenTipFooterProperty

ScreenTipHeaderProperty

Identifies the ScreenTipHeader dependency property. This field is read-only.

public static readonly DependencyProperty ScreenTipHeaderProperty

SmallImageSourceProperty

Identifies the SmallImageSource dependency property. This field is read-only.

public static readonly DependencyProperty SmallImageSourceProperty

StaysOpenOnClickProperty

Identifies the StaysOpenOnClick dependency property. This field is read-only.

public static readonly DependencyProperty StaysOpenOnClickProperty

TitleProperty

Identifies the Title dependency property. This field is read-only.

public static readonly DependencyProperty TitleProperty

ToolBarItemCollapseBehaviorProperty

Identifies the ToolBarItemCollapseBehavior dependency property. This field is read-only.

public static readonly DependencyProperty ToolBarItemCollapseBehaviorProperty

ToolBarItemVariantBehaviorProperty

Identifies the ToolBarItemVariantBehavior dependency property. This field is read-only.

public static readonly DependencyProperty ToolBarItemVariantBehaviorProperty

UserInterfaceDensityProperty

Identifies the UserInterfaceDensity dependency property. This field is read-only.

public static readonly DependencyProperty UserInterfaceDensityProperty

VariantSizeProperty

Identifies the VariantSize dependency property. This field is read-only.

public static readonly DependencyProperty VariantSizeProperty