Skip to main content

Button Class

NuGet: GHIElectronics.TinyCLR.UI
Assembly: GHIElectronics.TinyCLR.UI
Namespace: GHIElectronics.TinyCLR.UI.Controls

A clickable push button that raises Click when activated.

public class Button : ContentControl, IDisposable

Constructors​

Button()​

public Button()

Creates a new Button.

Properties​

Alpha​

public ushort Alpha { get; set; }

Opacity (0-255) used when drawing the button image.

RadiusBorder​

public int RadiusBorder { get; set; }

Corner radius used by the nine-slice button image.

BackgroundImage​

public ImageSource BackgroundImage { get; set; }

Optional custom face image, nine-slice scaled with RadiusBorder. When set it replaces the default themed button skin (and takes priority over Control.Background).

ClickMode​

public ClickMode ClickMode { get; set; }

Determines whether Click fires on touch press or release. Default is ClickMode.Release (WPF convention); set to ClickMode.Press for the instant TinyCLR 2.x response (fires the moment the button is touched).

IsPressed​

public bool IsPressed { get; }

True while the button is held down.

Methods​

ArrangeOverride(int arrangeWidth, int arrangeHeight)​

protected override void ArrangeOverride(int arrangeWidth, int arrangeHeight)

Places the content (ContentControl.Child) inside the button face according to ContentControl.HorizontalContentAlignment / ContentControl.VerticalContentAlignment. For the default Center/Center this sizes the child to its desired size and centers it; Stretch fills the face (the pre-existing behavior).

OnTouchUp(TouchEventArgs e)​

protected override void OnTouchUp(TouchEventArgs e)

Handles touch release; fires Click if the press started on this button.

OnTouchDown(TouchEventArgs e)​

protected override void OnTouchDown(TouchEventArgs e)

Handles touch press; marks the button as pressed (and, in ClickMode.Press mode, fires Click immediately).

OnButtonDown(ButtonEventArgs e)​

protected override void OnButtonDown(ButtonEventArgs e)

Handles the Select hardware button press; marks the button as pressed.

OnButtonUp(ButtonEventArgs e)​

protected override void OnButtonUp(ButtonEventArgs e)

Handles the Select hardware button release; fires Click if it was pressed.

OnRender(DrawingContext dc)​

public override void OnRender(DrawingContext dc)

Draws the button in its pressed or unpressed state.

Dispose()​

public void Dispose()

Releases the resources used by the button.

Dispose(bool disposing)​

protected virtual void Dispose(bool disposing)

Releases the button's bitmap resources and event subscriptions.

Events​

Click​

public event RoutedEventHandler Click

Raised when the button is clicked.