In This Article

BarToggleButton Class

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

[PseudoClasses(new string[] { ":checked", ":unchecked" })]
public class BarToggleButton : BarButton, 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 BarButton object
Derived:
BarCheckBox
Implements:
IDataContextProvider ILogical IThemeVariantHost IResourceHost IResourceNode IStyleHost ISetLogicalParent ISetInheritanceParent IStyleable INamed IInputElement IDataTemplateHost ISetterValue ICommandSource

Constructors

BarToggleButton()

Initializes a new instance of the class.

public BarToggleButton()

Properties

IsChecked

Whether the control is checked.

public bool IsChecked { get; set; }

Property Value

bool:

The default value is false.

StyleKeyOverride

Gets the type by which the element is styled.

protected override Type StyleKeyOverride { get; }

Property Value

Type

Remarks

Usually controls are styled by their own type, but there are instances where you want an element to be styled by its base type, e.g. creating SpecialButton that derives from Button and adds extra functionality but is still styled as a regular Button. Override this property to change the style for a control class, returning the type that you wish the elements to be styled as.

Methods

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.

OnIsCheckedChanged()

Invokes the IsCheckedChanged event.

protected virtual void OnIsCheckedChanged()

Toggle()

Toggles the button.

protected virtual void Toggle()

Events

IsCheckedChanged

Occurs when the IsChecked property is changed.

public event EventHandler<RoutedEventArgs>? IsCheckedChanged

Event Type

EventHandler<RoutedEventArgs>

Fields

IsCheckedChangedEvent

Defines the IsCheckedChanged event.

public static readonly RoutedEvent<RoutedEventArgs> IsCheckedChangedEvent

IsCheckedProperty

Defines the IsChecked property.

public static readonly StyledProperty<bool> IsCheckedProperty

Inherited Members

Extension Methods