Table of Contents

Class ToggleSwitch

Namespace
Avalonia.Controls
Assembly
Avalonia.Controls.dll

A Toggle Switch control.

[TemplatePart("PART_MovingKnobs", typeof(Panel), IsRequired = true)]
[TemplatePart("PART_OffContentPresenter", typeof(ContentPresenter))]
[TemplatePart("PART_OnContentPresenter", typeof(ContentPresenter))]
[TemplatePart("PART_SwitchKnob", typeof(Panel))]
[PseudoClasses(new string[] { ":dragging" })]
public class ToggleSwitch : ToggleButton, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue, ICommandSource
Inheritance
ToggleSwitch
Implements
Inherited Members
Extension Methods

Constructors

ToggleSwitch()

public ToggleSwitch()

Fields

KnobTransitionsProperty

Defines the KnobTransitions property.

public static readonly StyledProperty<Transitions> KnobTransitionsProperty

Field Value

StyledProperty<Transitions>

OffContentProperty

Defines the OffContent property.

public static readonly StyledProperty<object?> OffContentProperty

Field Value

StyledProperty<object>

OffContentTemplateProperty

Defines the OffContentTemplate property.

public static readonly StyledProperty<IDataTemplate?> OffContentTemplateProperty

Field Value

StyledProperty<IDataTemplate>

OnContentProperty

Defines the OnContent property.

public static readonly StyledProperty<object?> OnContentProperty

Field Value

StyledProperty<object>

OnContentTemplateProperty

Defines the OnContentTemplate property.

public static readonly StyledProperty<IDataTemplate?> OnContentTemplateProperty

Field Value

StyledProperty<IDataTemplate>

Properties

KnobTransitions

Gets or Sets the Transitions of switching knob.

public Transitions KnobTransitions { get; set; }

Property Value

Transitions

OffContent

Gets or Sets the Content that is displayed when in the Off State.

public object? OffContent { get; set; }

Property Value

object

OffContentPresenter

public ContentPresenter? OffContentPresenter { get; }

Property Value

ContentPresenter

OffContentTemplate

Gets or Sets the IDataTemplate used to display the OffContent.

public IDataTemplate? OffContentTemplate { get; set; }

Property Value

IDataTemplate

OnContent

Gets or Sets the Content that is displayed when in the On State.

public object? OnContent { get; set; }

Property Value

object

OnContentPresenter

public ContentPresenter? OnContentPresenter { get; }

Property Value

ContentPresenter

OnContentTemplate

Gets or Sets the IDataTemplate used to display the OnContent.

public IDataTemplate? OnContentTemplate { get; set; }

Property Value

IDataTemplate

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)

Parameters

e TemplateAppliedEventArgs

The event args.

OnLoaded(RoutedEventArgs)

Invoked just before the Loaded event.

protected override void OnLoaded(RoutedEventArgs e)

Parameters

e RoutedEventArgs

The event args.

RegisterContentPresenter(ContentPresenter)

Called when an ContentPresenter is registered with the control.

protected override bool RegisterContentPresenter(ContentPresenter presenter)

Parameters

presenter ContentPresenter

The presenter.

Returns

bool