Table of Contents

Class ToggleButton

Namespace
Myra.Graphics2D.UI
Assembly
Myra.dll

A toggle button widget that can be toggled between two states.

public class ToggleButton : ButtonBase, IItemWithId, INotifyAttachedPropertyChanged, IContent
Inheritance
ToggleButton
Implements
Inherited Members

Constructors

ToggleButton(Stylesheet, string)

Initializes a new instance of the ToggleButton class with the specified stylesheet and style.

public ToggleButton(Stylesheet stylesheet, string styleName = "")

Parameters

stylesheet Stylesheet

The stylesheet to use for applying the style.

styleName string

The name of the style to apply. Defaults to the default stylesheet style.

ToggleButton(string)

Initializes a new instance of the ToggleButton class with the specified style.

public ToggleButton(string styleName = "")

Parameters

styleName string

The name of the style to apply. Defaults to the default stylesheet style.

Properties

Content

Gets or sets the content widget displayed inside the toggle button.

[Browsable(false)]
public override Widget Content { get; set; }

Property Value

Widget

IsToggled

Gets or sets a value indicating whether the toggle button is in the toggled (pressed) state.

public bool IsToggled { get; set; }

Property Value

bool

Methods

CreateTextButton(string)

Creates a toggle button with a text label as its content.

public static ToggleButton CreateTextButton(string text)

Parameters

text string

The text to display on the button.

Returns

ToggleButton

A new ToggleButton with a text label.

InternalOnTouchDown()

Called when a touch point is pressed on the toggle button, toggling its state.

protected override void InternalOnTouchDown()

InternalOnTouchUp()

Called when a touch point is released on the toggle button.

protected override void InternalOnTouchUp()

OnKeyDown(Keys)

Handles keyboard input for the toggle button, toggling state when Space is pressed.

public override void OnKeyDown(Keys k)

Parameters

k Keys

The key being pressed.

Events

IsToggledChanged

Occurs when the toggled state of the toggle button changes.

public event MyraEventHandler IsToggledChanged

Event Type

MyraEventHandler