In This Article

BarButton Class

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

[PseudoClasses(new string[] { ":layout-mode-classic", ":layout-mode-simplified" })]
[PseudoClasses(new string[] { ":variant-small", ":variant-medium", ":variant-large" })]
[PseudoClasses(new string[] { ":image-only", ":label-only", ":image-and-label" })]
[PseudoClasses(new string[] { ":layout-orientation-vertical" })]
public class BarButton : Button, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue, ICommandSource
Inheritance:
object AvaloniaObject Animatable StyledElement Visual Layoutable Interactive InputElement Control TemplatedControl ContentControl Button object
Derived:
BarToggleButton RibbonGroupCollapsedButton RibbonQuickAccessToolBarOverflowButton StandaloneToolBarOverflowButton RibbonApplicationButton
Implements:
IDataContextProvider ILogical IThemeVariantHost IResourceHost IResourceNode IStyleHost ISetLogicalParent ISetInheritanceParent IStyleable INamed IInputElement IDataTemplateHost ISetterValue ICommandSource

Constructors

BarButton()

Initializes a new instance of the class.

public BarButton()

Properties

CanCloneToRibbonQuickAccessToolBar

Whether the control can be cloned to the ribbon quick-access toolbar.

public bool CanCloneToRibbonQuickAccessToolBar { get; set; }

Property Value

bool:

The default value is true.

HasLabel

Whether the control has a Label available.

public bool HasLabel { get; }

Property Value

bool:

The default value is false.

IconResolved

The resolved object representing the icon to use in the control's template.

public object? IconResolved { get; }

Property Value

object

InputGesture

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

public KeyGesture? InputGesture { get; set; }

Property Value

KeyGesture

IsInputGestureTextVisible

Indicates whether the input gesture text is allowed to be visible in the user interface.

public bool IsInputGestureTextVisible { get; set; }

Property Value

bool:

The default value is true.

Key

A string that uniquely identifies the control.

public string? Key { get; set; }

Property Value

string

KeyTipText

The key tip text used to access the control.

public string? KeyTipText { get; set; }

Property Value

string

Label

The text label to display.

public string? Label { get; set; }

Property Value

string

LargeIcon

The object representing a large icon, generally 32x32 size.

public object? LargeIcon { get; set; }

Property Value

object

MediumIcon

The object representing a medium icon, generally 24x24 size.

public object? MediumIcon { get; set; }

Property Value

object

ScreenTipFooter

The screen tip footer content.

public object? ScreenTipFooter { get; set; }

Property Value

object

ScreenTipHeader

The screen tip header content.

public object? ScreenTipHeader { get; set; }

Property Value

object

SmallIcon

The object representing a small icon, generally 16x16 size.

public object? SmallIcon { get; set; }

Property Value

object

Title

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

public string? Title { get; set; }

Property Value

string

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.

VariantSize

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 default value is Small.

Methods

OnApplyTemplate(TemplateAppliedEventArgs)

Called when the control's template is applied. In simple terms, this means the method is called just before the control is displayed.

protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
Parameter Type Description
e TemplateAppliedEventArgs

The event args.

OnClick()

Invokes the Avalonia.Controls.Button.Click event.

protected override void OnClick()

OnCreateAutomationPeer()

Returns a new, type-specific Avalonia.Automation.Peers.AutomationPeer implementation for the control.

protected override AutomationPeer OnCreateAutomationPeer()

Returns

AutomationPeer:

The type-specific Avalonia.Automation.Peers.AutomationPeer implementation.

OnFlyoutClosed()

Invoked when the button's flyout is closed.

protected override void OnFlyoutClosed()

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.

OnKeyTipOpening(KeyTipOpeningEventArgs)

Occurs when the control's key tip is opening.

protected virtual void OnKeyTipOpening(KeyTipOpeningEventArgs e)
Parameter Type Description
e KeyTipOpeningEventArgs

The KeyTipOpeningEventArgs containing data related to this event.

ToString()

Returns the string representation of this object.

public override string ToString()

Returns

string:

The string representation of this object.

UpdateDataValidation(AvaloniaProperty, BindingValueType, Exception?)

Called to update the validation state for properties for which data validation is enabled.

protected override void UpdateDataValidation(AvaloniaProperty property, BindingValueType state, Exception? error)
Parameter Type Description
property AvaloniaProperty

The property.

state BindingValueType

The current data binding state.

error Exception

The current data binding error, if any.

Fields

CanCloneToRibbonQuickAccessToolBarProperty

Defines the CanCloneToRibbonQuickAccessToolBar property.

public static readonly StyledProperty<bool> CanCloneToRibbonQuickAccessToolBarProperty

HasLabelProperty

Defines the HasLabel property.

public static readonly StyledProperty<bool> HasLabelProperty

IconResolvedProperty

Defines the IconResolved property.

public static readonly StyledProperty<object?> IconResolvedProperty

InputGestureProperty

Defines the InputGesture property.

public static readonly StyledProperty<KeyGesture?> InputGestureProperty

IsInputGestureTextVisibleProperty

Defines the IsInputGestureTextVisible property.

public static readonly StyledProperty<bool> IsInputGestureTextVisibleProperty

KeyProperty

Defines the Key property.

public static readonly StyledProperty<string?> KeyProperty

KeyTipTextProperty

Defines the KeyTipText property.

public static readonly StyledProperty<string?> KeyTipTextProperty

LabelProperty

Defines the Label property.

public static readonly StyledProperty<string?> LabelProperty

LargeIconProperty

Defines the LargeIcon property.

public static readonly StyledProperty<object?> LargeIconProperty

MediumIconProperty

Defines the MediumIcon property.

public static readonly StyledProperty<object?> MediumIconProperty

ScreenTipFooterProperty

Defines the ScreenTipFooter property.

public static readonly StyledProperty<object?> ScreenTipFooterProperty

ScreenTipHeaderProperty

Defines the ScreenTipHeader property.

public static readonly StyledProperty<object?> ScreenTipHeaderProperty

SmallIconProperty

Defines the SmallIcon property.

public static readonly StyledProperty<object?> SmallIconProperty

TitleProperty

Defines the Title property.

public static readonly StyledProperty<string?> TitleProperty

ToolBarItemCollapseBehaviorProperty

Defines the ToolBarItemCollapseBehavior property.

public static readonly StyledProperty<ItemCollapseBehavior> ToolBarItemCollapseBehaviorProperty

ToolBarItemVariantBehaviorProperty

Defines the ToolBarItemVariantBehavior property.

public static readonly StyledProperty<ItemVariantBehavior> ToolBarItemVariantBehaviorProperty

VariantSizeProperty

Defines the VariantSize property.

public static readonly StyledProperty<VariantSize> VariantSizeProperty

Inherited Members

  • Button.ClickModeProperty
  • Button.CommandProperty
  • Button.HotKeyProperty
  • Button.CommandParameterProperty
  • Button.IsDefaultProperty
  • Button.IsCancelProperty
  • Button.ClickEvent
  • Button.IsPressedProperty
  • Button.FlyoutProperty
  • Button.OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)
  • Button.OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)
  • Button.OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs)
  • Button.OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs)
  • Button.OnAccessKey(RoutedEventArgs)
  • Button.OnKeyDown(KeyEventArgs)
  • Button.OnKeyUp(KeyEventArgs)
  • Button.OpenFlyout()
  • Button.CloseFlyout()
  • Button.OnFlyoutOpened()
  • Button.OnPointerPressed(PointerPressedEventArgs)
  • Button.OnPointerReleased(PointerReleasedEventArgs)
  • Button.OnPointerCaptureLost(PointerCaptureLostEventArgs)
  • Button.OnLostFocus(RoutedEventArgs)
  • Button.OnPropertyChanged(AvaloniaPropertyChangedEventArgs)
  • Button.ClickMode
  • Button.Command
  • Button.HotKey
  • Button.CommandParameter
  • Button.IsDefault
  • Button.IsCancel
  • Button.IsPressed
  • Button.Flyout
  • Button.IsEnabledCore
  • Button.Click
  • ContentControl.ContentProperty
  • ContentControl.ContentTemplateProperty
  • ContentControl.HorizontalContentAlignmentProperty
  • ContentControl.VerticalContentAlignmentProperty
  • ContentControl.RegisterContentPresenter(ContentPresenter)
  • ContentControl.Content
  • ContentControl.ContentTemplate
  • ContentControl.Presenter
  • ContentControl.HorizontalContentAlignment
  • ContentControl.VerticalContentAlignment
  • TemplatedControl.BackgroundProperty
  • TemplatedControl.BackgroundSizingProperty
  • TemplatedControl.BorderBrushProperty
  • TemplatedControl.BorderThicknessProperty
  • TemplatedControl.CornerRadiusProperty
  • TemplatedControl.FontFamilyProperty
  • TemplatedControl.FontFeaturesProperty
  • TemplatedControl.FontSizeProperty
  • TemplatedControl.FontStyleProperty
  • TemplatedControl.FontWeightProperty
  • TemplatedControl.FontStretchProperty
  • TemplatedControl.ForegroundProperty
  • TemplatedControl.PaddingProperty
  • TemplatedControl.TemplateProperty
  • TemplatedControl.IsTemplateFocusTargetProperty
  • TemplatedControl.TemplateAppliedEvent
  • TemplatedControl.GetIsTemplateFocusTarget(Control)
  • TemplatedControl.SetIsTemplateFocusTarget(Control, bool)
  • TemplatedControl.ApplyTemplate()
  • TemplatedControl.GetTemplateFocusTarget()
  • TemplatedControl.OnTemplateChanged(AvaloniaPropertyChangedEventArgs)
  • TemplatedControl.Background
  • TemplatedControl.BackgroundSizing
  • TemplatedControl.BorderBrush
  • TemplatedControl.BorderThickness
  • TemplatedControl.CornerRadius
  • TemplatedControl.FontFamily
  • TemplatedControl.FontFeatures
  • TemplatedControl.FontSize
  • TemplatedControl.FontStyle
  • TemplatedControl.FontWeight
  • TemplatedControl.FontStretch
  • TemplatedControl.Foreground
  • TemplatedControl.Padding
  • TemplatedControl.Template
  • TemplatedControl.TemplateApplied
  • Control.FocusAdornerProperty
  • Control.TagProperty
  • Control.ContextMenuProperty
  • Control.ContextFlyoutProperty
  • Control.RequestBringIntoViewEvent
  • Control.ContextRequestedEvent
  • Control.LoadedEvent
  • Control.UnloadedEvent
  • Control.SizeChangedEvent
  • Control.OnLoaded(RoutedEventArgs)
  • Control.OnUnloaded(RoutedEventArgs)
  • Control.OnSizeChanged(SizeChangedEventArgs)
  • Control.OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs)
  • Control.OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs)
  • Control.OnGotFocus(GotFocusEventArgs)
  • Control.FocusAdorner
  • Control.DataTemplates
  • Control.ContextMenu
  • Control.ContextFlyout
  • Control.IsLoaded
  • Control.Tag
  • Control.ContextRequested
  • Control.Loaded
  • Control.Unloaded
  • Control.SizeChanged
  • InputElement.FocusableProperty
  • InputElement.IsEnabledProperty
  • InputElement.IsEffectivelyEnabledProperty
  • InputElement.CursorProperty
  • InputElement.IsKeyboardFocusWithinProperty
  • InputElement.IsFocusedProperty
  • InputElement.IsHitTestVisibleProperty
  • InputElement.IsPointerOverProperty
  • InputElement.IsTabStopProperty
  • InputElement.GotFocusEvent
  • InputElement.LostFocusEvent
  • InputElement.KeyDownEvent
  • InputElement.KeyUpEvent
  • InputElement.TabIndexProperty
  • InputElement.TextInputEvent
  • InputElement.TextInputMethodClientRequestedEvent
  • InputElement.PointerEnteredEvent
  • InputElement.PointerExitedEvent
  • InputElement.PointerMovedEvent
  • InputElement.PointerPressedEvent
  • InputElement.PointerReleasedEvent
  • InputElement.PointerCaptureLostEvent
  • InputElement.PointerWheelChangedEvent
  • InputElement.TappedEvent
  • InputElement.HoldingEvent
  • InputElement.DoubleTappedEvent
  • InputElement.Focus(NavigationMethod, KeyModifiers)
  • InputElement.OnTextInput(TextInputEventArgs)
  • InputElement.OnPointerEntered(PointerEventArgs)
  • InputElement.OnPointerExited(PointerEventArgs)
  • InputElement.OnPointerMoved(PointerEventArgs)
  • InputElement.OnPointerWheelChanged(PointerWheelEventArgs)
  • InputElement.UpdateIsEffectivelyEnabled()
  • InputElement.Focusable
  • InputElement.IsEnabled
  • InputElement.Cursor
  • InputElement.IsKeyboardFocusWithin
  • InputElement.IsFocused
  • InputElement.IsHitTestVisible
  • InputElement.IsPointerOver
  • InputElement.IsTabStop
  • InputElement.IsEffectivelyEnabled
  • InputElement.TabIndex
  • InputElement.KeyBindings
  • InputElement.GestureRecognizers
  • InputElement.GotFocus
  • InputElement.LostFocus
  • InputElement.KeyDown
  • InputElement.KeyUp
  • InputElement.TextInput
  • InputElement.TextInputMethodClientRequested
  • InputElement.PointerEntered
  • InputElement.PointerExited
  • InputElement.PointerMoved
  • InputElement.PointerPressed
  • InputElement.PointerReleased
  • InputElement.PointerCaptureLost
  • InputElement.PointerWheelChanged
  • InputElement.Tapped
  • InputElement.Holding
  • InputElement.DoubleTapped
  • Interactive.AddHandler(RoutedEvent, Delegate, RoutingStrategies, bool)
  • Interactive.AddHandler<TEventArgs>(RoutedEvent<TEventArgs>, EventHandler<TEventArgs>, RoutingStrategies, bool)
  • Interactive.RemoveHandler(RoutedEvent, Delegate)
  • Interactive.RemoveHandler<TEventArgs>(RoutedEvent<TEventArgs>, EventHandler<TEventArgs>)
  • Interactive.RaiseEvent(RoutedEventArgs)
  • Interactive.BuildEventRoute(RoutedEvent)
  • Layoutable.DesiredSizeProperty
  • Layoutable.WidthProperty
  • Layoutable.HeightProperty
  • Layoutable.MinWidthProperty
  • Layoutable.MaxWidthProperty
  • Layoutable.MinHeightProperty
  • Layoutable.MaxHeightProperty
  • Layoutable.MarginProperty
  • Layoutable.HorizontalAlignmentProperty
  • Layoutable.VerticalAlignmentProperty
  • Layoutable.UseLayoutRoundingProperty
  • Layoutable.UpdateLayout()
  • Layoutable.Measure(Size)
  • Layoutable.Arrange(Rect)
  • Layoutable.InvalidateMeasure()
  • Layoutable.InvalidateArrange()
  • Layoutable.AffectsMeasure<T>(params AvaloniaProperty[])
  • Layoutable.AffectsArrange<T>(params AvaloniaProperty[])
  • Layoutable.MeasureCore(Size)
  • Layoutable.MeasureOverride(Size)
  • Layoutable.ArrangeCore(Rect)
  • Layoutable.ArrangeOverride(Size)
  • Layoutable.OnMeasureInvalidated()
  • Layoutable.OnVisualParentChanged(Visual, Visual)
  • Layoutable.Width
  • Layoutable.Height
  • Layoutable.MinWidth
  • Layoutable.MaxWidth
  • Layoutable.MinHeight
  • Layoutable.MaxHeight
  • Layoutable.Margin
  • Layoutable.HorizontalAlignment
  • Layoutable.VerticalAlignment
  • Layoutable.DesiredSize
  • Layoutable.IsMeasureValid
  • Layoutable.IsArrangeValid
  • Layoutable.UseLayoutRounding
  • Layoutable.EffectiveViewportChanged
  • Layoutable.LayoutUpdated
  • Visual.BoundsProperty
  • Visual.ClipToBoundsProperty
  • Visual.ClipProperty
  • Visual.IsVisibleProperty
  • Visual.OpacityProperty
  • Visual.OpacityMaskProperty
  • Visual.EffectProperty
  • Visual.HasMirrorTransformProperty
  • Visual.RenderTransformProperty
  • Visual.RenderTransformOriginProperty
  • Visual.FlowDirectionProperty
  • Visual.VisualParentProperty
  • Visual.ZIndexProperty
  • Visual.GetFlowDirection(Visual)
  • Visual.SetFlowDirection(Visual, FlowDirection)
  • Visual.InvalidateVisual()
  • Visual.Render(DrawingContext)
  • Visual.AffectsRender<T>(params AvaloniaProperty[])
  • Visual.LogicalChildrenCollectionChanged(object, NotifyCollectionChangedEventArgs)
  • Visual.InvalidateMirrorTransform()
  • Visual.Bounds
  • Visual.ClipToBounds
  • Visual.Clip
  • Visual.IsEffectivelyVisible
  • Visual.IsVisible
  • Visual.Opacity
  • Visual.OpacityMask
  • Visual.Effect
  • Visual.HasMirrorTransform
  • Visual.RenderTransform
  • Visual.RenderTransformOrigin
  • Visual.FlowDirection
  • Visual.ZIndex
  • Visual.VisualChildren
  • Visual.VisualRoot
  • Visual.BypassFlowDirectionPolicies
  • Visual.AttachedToVisualTree
  • Visual.DetachedFromVisualTree
  • StyledElement.DataContextProperty
  • StyledElement.NameProperty
  • StyledElement.ParentProperty
  • StyledElement.TemplatedParentProperty
  • StyledElement.ThemeProperty
  • StyledElement.BeginInit()
  • StyledElement.EndInit()
  • StyledElement.ApplyStyling()
  • StyledElement.InitializeIfNeeded()
  • StyledElement.TryGetResource(object, ThemeVariant, out object)
  • StyledElement.OnDataContextChanged(EventArgs)
  • StyledElement.OnDataContextBeginUpdate()
  • StyledElement.OnDataContextEndUpdate()
  • StyledElement.OnInitialized()
  • StyledElement.Name
  • StyledElement.Classes
  • StyledElement.DataContext
  • StyledElement.IsInitialized
  • StyledElement.Styles
  • StyledElement.StyleKey
  • StyledElement.Resources
  • StyledElement.TemplatedParent
  • StyledElement.Theme
  • StyledElement.LogicalChildren
  • StyledElement.PseudoClasses
  • StyledElement.StyleKeyOverride
  • StyledElement.Parent
  • StyledElement.ActualThemeVariant
  • StyledElement.AttachedToLogicalTree
  • StyledElement.DetachedFromLogicalTree
  • StyledElement.DataContextChanged
  • StyledElement.Initialized
  • StyledElement.ResourcesChanged
  • StyledElement.ActualThemeVariantChanged
  • Animatable.TransitionsProperty
  • Animatable.OnPropertyChangedCore(AvaloniaPropertyChangedEventArgs)
  • Animatable.Transitions
  • AvaloniaObject.CheckAccess()
  • AvaloniaObject.VerifyAccess()
  • AvaloniaObject.ClearValue(AvaloniaProperty)
  • AvaloniaObject.ClearValue<T>(AvaloniaProperty<T>)
  • AvaloniaObject.ClearValue<T>(StyledProperty<T>)
  • AvaloniaObject.ClearValue<T>(DirectPropertyBase<T>)
  • AvaloniaObject.Equals(object)
  • AvaloniaObject.GetHashCode()
  • AvaloniaObject.GetValue(AvaloniaProperty)
  • AvaloniaObject.GetValue<T>(StyledProperty<T>)
  • AvaloniaObject.GetValue<T>(DirectPropertyBase<T>)
  • AvaloniaObject.GetBaseValue<T>(StyledProperty<T>)
  • AvaloniaObject.IsAnimating(AvaloniaProperty)
  • AvaloniaObject.IsSet(AvaloniaProperty)
  • AvaloniaObject.SetValue(AvaloniaProperty, object, BindingPriority)
  • AvaloniaObject.SetValue<T>(StyledProperty<T>, T, BindingPriority)
  • AvaloniaObject.SetValue<T>(DirectPropertyBase<T>, T)
  • AvaloniaObject.SetCurrentValue(AvaloniaProperty, object)
  • AvaloniaObject.SetCurrentValue<T>(StyledProperty<T>, T)
  • AvaloniaObject.Bind(AvaloniaProperty, IBinding)
  • AvaloniaObject.Bind(AvaloniaProperty, IObservable<object>, BindingPriority)
  • AvaloniaObject.Bind<T>(StyledProperty<T>, IObservable<object>, BindingPriority)
  • AvaloniaObject.Bind<T>(StyledProperty<T>, IObservable<T>, BindingPriority)
  • AvaloniaObject.Bind<T>(StyledProperty<T>, IObservable<BindingValue<T>>, BindingPriority)
  • AvaloniaObject.Bind<T>(DirectPropertyBase<T>, IObservable<object>)
  • AvaloniaObject.Bind<T>(DirectPropertyBase<T>, IObservable<T>)
  • AvaloniaObject.Bind<T>(DirectPropertyBase<T>, IObservable<BindingValue<T>>)
  • AvaloniaObject.CoerceValue(AvaloniaProperty)
  • AvaloniaObject.RaisePropertyChanged<T>(DirectPropertyBase<T>, T, T)
  • AvaloniaObject.SetAndRaise<T>(DirectPropertyBase<T>, ref T, T)
  • AvaloniaObject.InheritanceParent
  • AvaloniaObject.this[AvaloniaProperty]
  • AvaloniaObject.this[IndexerDescriptor]
  • AvaloniaObject.PropertyChanged
  • object.GetType()
  • object.MemberwiseClone()
  • object.Equals(object, object)
  • object.ReferenceEquals(object, object)

Extension Methods