Table of Contents

Class Expander

Namespace
Avalonia.Controls
Assembly
Avalonia.Controls.dll

A control with a header that has a collapsible content section.

[PseudoClasses(new string[] { ":expanded", ":up", ":down", ":left", ":right" })]
public class Expander : HeaderedContentControl, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue
Inheritance
Expander
Implements
Inherited Members
Extension Methods

Constructors

Expander()

Initializes a new instance of the Expander class.

public Expander()

Fields

CollapsedEvent

Defines the Collapsed event.

public static readonly RoutedEvent<RoutedEventArgs> CollapsedEvent

Field Value

RoutedEvent<RoutedEventArgs>

CollapsingEvent

Defines the Collapsing event.

public static readonly RoutedEvent<CancelRoutedEventArgs> CollapsingEvent

Field Value

RoutedEvent<CancelRoutedEventArgs>

ContentTransitionProperty

Defines the ContentTransition property.

public static readonly StyledProperty<IPageTransition?> ContentTransitionProperty

Field Value

StyledProperty<IPageTransition>

ExpandDirectionProperty

Defines the ExpandDirection property.

public static readonly StyledProperty<ExpandDirection> ExpandDirectionProperty

Field Value

StyledProperty<ExpandDirection>

ExpandedEvent

Defines the Expanded event.

public static readonly RoutedEvent<RoutedEventArgs> ExpandedEvent

Field Value

RoutedEvent<RoutedEventArgs>

ExpandingEvent

Defines the Expanding event.

public static readonly RoutedEvent<CancelRoutedEventArgs> ExpandingEvent

Field Value

RoutedEvent<CancelRoutedEventArgs>

IsExpandedProperty

Defines the IsExpanded property.

public static readonly StyledProperty<bool> IsExpandedProperty

Field Value

StyledProperty<bool>

Properties

ContentTransition

Gets or sets the transition used when expanding or collapsing the content.

public IPageTransition? ContentTransition { get; set; }

Property Value

IPageTransition

ExpandDirection

Gets or sets the direction in which the Expander opens.

public ExpandDirection ExpandDirection { get; set; }

Property Value

ExpandDirection

IsExpanded

Gets or sets a value indicating whether the Expander content area is open and visible.

public bool IsExpanded { get; set; }

Property Value

bool

Methods

OnCoerceIsExpanded(bool)

Called when the IsExpanded property has to be coerced.

protected virtual bool OnCoerceIsExpanded(bool value)

Parameters

value bool

The value to coerce.

Returns

bool

OnCollapsed(RoutedEventArgs)

Invoked just before the Collapsed event.

protected virtual void OnCollapsed(RoutedEventArgs eventArgs)

Parameters

eventArgs RoutedEventArgs

OnCollapsing(CancelRoutedEventArgs)

Invoked just before the Collapsing event.

protected virtual void OnCollapsing(CancelRoutedEventArgs eventArgs)

Parameters

eventArgs CancelRoutedEventArgs

OnExpanded(RoutedEventArgs)

Invoked just before the Expanded event.

protected virtual void OnExpanded(RoutedEventArgs eventArgs)

Parameters

eventArgs RoutedEventArgs

OnExpanding(CancelRoutedEventArgs)

Invoked just before the Expanding event.

protected virtual void OnExpanding(CancelRoutedEventArgs eventArgs)

Parameters

eventArgs CancelRoutedEventArgs

OnPropertyChanged(AvaloniaPropertyChangedEventArgs)

Called when a avalonia property changes on the object.

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)

Parameters

change AvaloniaPropertyChangedEventArgs

The property change details.

Events

Collapsed

Occurs after the content area has closed and only the header is visible.

public event EventHandler<RoutedEventArgs>? Collapsed

Event Type

EventHandler<RoutedEventArgs>

Collapsing

Occurs as the content area is closing.

public event EventHandler<CancelRoutedEventArgs>? Collapsing

Event Type

EventHandler<CancelRoutedEventArgs>

Remarks

The event args Cancel property may be set to true to cancel the event and keep the control open (expanded).

Expanded

Occurs after the Expander has opened to display both its header and content.

public event EventHandler<RoutedEventArgs>? Expanded

Event Type

EventHandler<RoutedEventArgs>

Expanding

Occurs as the content area is opening.

public event EventHandler<CancelRoutedEventArgs>? Expanding

Event Type

EventHandler<CancelRoutedEventArgs>

Remarks

The event args Cancel property may be set to true to cancel the event and keep the control closed (collapsed).