Skip to content

ToggleSwitch Class

Represents a button that can be toggled on/off within a group of other buttons.

C#
[DataContract]
public class ToggleSwitch : ToggleButtonBase

Inheritance objectControlBaseButtonBaseToggleButtonBase

Creates a new checkbox control with the specified width and height.

C#
public ToggleSwitch(int width, int height)

width int
The width of the control.

height int
The height of the control.

The on glyph of the switch.

C#
[DataMember]
public int OnGlyph { get; set; }

The background glyph of the switch.

C#
[DataMember]
public int BackgroundGlyph { get; set; }

The color of the OnGlyph when the control is IsSelected is true.

C#
[DataMember]
public Color OnGlyphColor { get; set; }

The color of the OnGlyph when the control is IsSelected is false.

C#
[DataMember]
public Color OffGlyphColor { get; set; }

The theme state used for the switch.

C#
public ThemeStates SwitchThemeState { get; protected set; }

The orientation of the toggle switch relative to the text.

C#
public HorizontalAlignment SwitchOrientation { get; set; }

Valid values are Left and Right.

Perfroms a click on the base button and also toggles the IsSelected property.

C#
protected override void OnClick()

Updates the ThemeState by calling RefreshTheme(Colors) with the provided colors. Override this method to adjust how colors are used by the ThemeState.

C#
protected override void RefreshThemeStateColors(Colors colors)

colors Colors
The colors to apply to the theme state.

Redraws the control if applicable.

C#
public override void UpdateAndRedraw(TimeSpan time)

time TimeSpan
The duration of thecurrent frame.