Table of Contents

Class Button

Namespace
Alternet.UI
Assembly
Alternet.UI.dll

Represents a button control.

[ControlCategory("Common")]
public class Button : ButtonBase, IBaseObject, IDisposableObject, IInputElement, ISupportInitialize, IFocusable, IWin32Window, IComponent, IDisposable, ITextProperty
Inheritance
Button
Implements
Extension Methods

Examples

Here is how to declare a Button in UIXML:

<Button Name="executeButton" Text="Execute" Click="ExecuteButton_Click"/>

And the corresponding event handler in the code-behind:

private void ExecuteButton_Click(object sender, System.EventArgs e)
{
    MessageBox.Show("Hello", "Message");
}

Also, a button can be created from code:

var button = new Button();
button.Text = "Hello, world!";
button.Click += ExecuteButton_Click;

Remarks

A button is one of the most commonly used UI controls. It is designed to mimic a real-world push button. When the user clicks on a button, the Click event is raised. This event is then handled to execute some code in response to the user clicking a button.

Examples of how a button can look on different platforms:

Set Text property to specify the text displayed on the control. A button, like any other Control, can be disabled by setting its Enabled property to false.

Constructors

Button()

Initializes a new Button instance.

Button(string)

Initializes a new Button instance with the specified text.

Properties

ControlKind

Returns control identifier.

DisabledImage

Gets or sets an Image for disabled control state.

ExactFit

Gets or sets whether buttons are made of at least the standard button size, even if their contents is small enough to fit into a smaller size.

FocusedImage

Gets or sets an Image for focused control state.

HasBorder

Gets or sets a value indicating whether the control has a border.

HoveredImage

Gets or sets an Image for hovered control state.

Image

Gets or sets the image that is displayed on a button control.

ImagesEnabled

Gets or sets whether images in buttons are available.

IsCancel

Gets or sets a value that indicates whether a Button is a Cancel button. In a modal dialog, a user can activate the Cancel button by pressing the ESC key.

IsDefault

Gets or sets a value that indicates whether a Button is the default button. In a modal dialog, a user invokes the default button by pressing the ENTER key.

PressedImage

Gets or sets an Image for pressed control state.

StateImages

Specifies a set of images for different Button states.

TextAlign

Sets the position at which the text is displayed.

TextVisible

Gets or sets visibility of the text in the bitmap.

Methods

SetImageMargins(double, double)

Sets the margins between the image and the text of the button.

SetImagePosition(GenericDirection)

Sets the position at which the image is displayed.