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 an instance of the class.
public BarButton()
Properties
CanCloneToRibbonQuickAccessToolBar
Indicates whether the control can be cloned to the ribbon quick-access toolbar.
public bool CanCloneToRibbonQuickAccessToolBar { get; set; }
Property Value
- bool:
trueif the control can be cloned to the ribbon quick-access toolbar; otherwise,false. The default value istrue.
HasLabel
Indicates whether the control has a Label available.
public bool HasLabel { get; }
Property Value
ImageSourceResolved
The resolved ImageSource for the image to use in the control's template.
InputGestureText
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
InvocationFocusBehavior
Indicates how the button processes focus when it is clicked.
public InvocationFocusBehavior InvocationFocusBehavior { get; set; }
Property Value
- InvocationFocusBehavior:
The default value is Default.
IsInputGestureTextVisible
Indicates whether the input gesture text is allowed to be visible in the user interface.
public bool IsInputGestureTextVisible { get; set; }
Property Value
- bool:
trueif the input gesture text is allowed to be visible in the user interface; otherwise,false. The default value istrue.
Key
A string that uniquely identifies the control.
[Localizability(LocalizationCategory.NeverLocalize)]
public string? Key { get; set; }
Property Value
KeyTipText
The key tip text used to access the control.
[Localizability(LocalizationCategory.Label)]
public string? KeyTipText { get; set; }
Property Value
Label
The text label to display.
[Localizability(LocalizationCategory.Label)]
public string? Label { get; set; }
Property Value
LargeImageSource
The ImageSource for a large image, generally 32x32 size.
MediumImageSource
The ImageSource for a medium image, generally 24x24 size.
ScreenTipFooter
The screen tip footer content.
ScreenTipHeader
The screen tip header content.
SmallImageSource
The ImageSource for a small image, generally 16x16 size.
StaysOpenOnClick
Indicates whether the button doesn't try to restore focus to the main focus scope when clicked.
[Obsolete("This property is obsolete and will be removed in a future version. To achieve same behavior when it is true, set the InvocationFocusBehavior property to None.", false)]
public bool StaysOpenOnClick { get; set; }
Property Value
- bool:
trueif the button doesn't try to restore focus to the main focus scope when clicked; otherwise,false. The default value isfalse.
Title
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
The ItemCollapseBehavior for the control when in a ribbon using Simplified layout mode.
public ItemCollapseBehavior ToolBarItemCollapseBehavior { get; set; }
Property Value
- ItemCollapseBehavior:
The default value is Default.
ToolBarItemVariantBehavior
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 default value is AlwaysSmall.
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.
VariantSize
The VariantSize currently assigned to the control.
public VariantSize VariantSize { get; set; }
Property Value
Remarks
This property should only be manually set when the control is standalone, and not hosted by a bar 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 event data. |
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.
Fields
CanCloneToRibbonQuickAccessToolBarProperty
Defines the CanCloneToRibbonQuickAccessToolBar property.
public static readonly DependencyProperty CanCloneToRibbonQuickAccessToolBarProperty
HasLabelProperty
Defines the HasLabel property.
public static readonly DependencyProperty HasLabelProperty
ImageSourceResolvedProperty
Defines the ImageSourceResolved property.
public static readonly DependencyProperty ImageSourceResolvedProperty
InputGestureTextProperty
Defines the InputGestureText property.
public static readonly DependencyProperty InputGestureTextProperty
InvocationFocusBehaviorProperty
Defines the InvocationFocusBehavior property.
public static readonly DependencyProperty InvocationFocusBehaviorProperty
IsInputGestureTextVisibleProperty
Defines the IsInputGestureTextVisible property.
public static readonly DependencyProperty IsInputGestureTextVisibleProperty
KeyProperty
Defines the Key property.
public static readonly DependencyProperty KeyProperty
KeyTipTextProperty
Defines the KeyTipText property.
public static readonly DependencyProperty KeyTipTextProperty
LabelProperty
Defines the Label property.
public static readonly DependencyProperty LabelProperty
LargeImageSourceProperty
Defines the LargeImageSource property.
public static readonly DependencyProperty LargeImageSourceProperty
MediumImageSourceProperty
Defines the MediumImageSource property.
public static readonly DependencyProperty MediumImageSourceProperty
ScreenTipFooterProperty
Defines the ScreenTipFooter property.
public static readonly DependencyProperty ScreenTipFooterProperty
ScreenTipHeaderProperty
Defines the ScreenTipHeader property.
public static readonly DependencyProperty ScreenTipHeaderProperty
SmallImageSourceProperty
Defines the SmallImageSource property.
public static readonly DependencyProperty SmallImageSourceProperty
StaysOpenOnClickProperty
Defines the StaysOpenOnClick property.
public static readonly DependencyProperty StaysOpenOnClickProperty
TitleProperty
Defines the Title property.
public static readonly DependencyProperty TitleProperty
ToolBarItemCollapseBehaviorProperty
Defines the ToolBarItemCollapseBehavior property.
public static readonly DependencyProperty ToolBarItemCollapseBehaviorProperty
ToolBarItemVariantBehaviorProperty
Defines the ToolBarItemVariantBehavior property.
public static readonly DependencyProperty ToolBarItemVariantBehaviorProperty
UserInterfaceDensityProperty
Defines the UserInterfaceDensity property.
public static readonly DependencyProperty UserInterfaceDensityProperty
VariantSizeProperty
Defines the VariantSize property.
public static readonly DependencyProperty VariantSizeProperty