Back to Devexpress

SimpleButton Class

mobilecontrols-devexpress-dot-xamarinforms-dot-editors-b07e52e1.md

latest6.6 KB
Original Source

SimpleButton Class

A simple button.

Namespace : DevExpress.XamarinForms.Editors

Assembly : DevExpress.XamarinForms.Editors.dll

NuGet Package : DevExpress.XamarinForms.Editors

Declaration

csharp
public class SimpleButton :
    View,
    IButtonController,
    IViewController,
    IVisualElementController,
    IElementController

Remarks

SimpleButton performs the assigned action when a user taps it. The control can display a caption string (Text), an icon (Icon), or both.

Use the following events to define how the button should respond to taps:

  • Pressed - Occurs when a user presses the button.

  • Released - Occurs when a user releases the button.

  • Clicked - Occurs when a user taps the button and then releases it. This event is fired right after the Released event, but if the user slides their finger away from the button before releasing it, the Clicked event does not occur.

Visual States and Appearance

The button has a different appearance in each state and provides the following properties to customize colors:

|

Button

|

Properties

| | --- | --- | |

Default

|

BorderColor
BackgroundColor
TextColor
IconColor

| |

Pressed (IsPressed)

|

PressedBorderColor
PressedBackgroundColor
PressedTextColor
PressedIconColor

| |

Disabled

|

DisabledBorderColor
DisabledBackgroundColor
DisabledTextColor
DisabledIconColor

|

You can also adjust the following appearance settings for all button states:

|

Property

|

Description

| | --- | --- | |

BorderThickness

|

Gets or sets the thickness of the button borders.

| |

CornerMode

|

Gets or sets whether button corners are rounded or cut.

| |

CornerRadius

|

Specifies the radius of the button corners.

| |

FontFamily
FontSize
FontAttributes

|

Configure the font settings.

| |

IconIndent
IconHorizontalPosition

|

Specify the icon position relative to the button caption.

| |

Padding

|

Gets or sets the distance between the button caption and borders.

| |

ShowShadow

|

Gets or sets the button shadow visibility.

| |

UseRippleEffect

|

Gets or sets whether the ripple animation effect is used.

| |

Content

|

Gets or sets the custom content of the button.

|

The following images show buttons with the corner radius set to 15 :

|

CornerMode = Round

|

CornerMode = Cut

|

Example

This example shows how to customize button appearance and handle the button click event.

|

Button State

|

Default Appearance

|

Custom Appearance

| | --- | --- | --- | |

Default

|

|

| |

Pressed

|

|

| |

Disabled

|

|

|

  1. Add the delete.png icon file to your platform-specific projects:

  2. Use the following properties to adjust the button’s appearance and handle the Clicked event to clear label1 on button tap:

Implements

Xamarin.Forms.IButtonController

Xamarin.Forms.IViewController

Xamarin.Forms.IVisualElementController

Xamarin.Forms.IElementController

Inheritance

Object SimpleButton

See Also

SimpleButton Members

DevExpress.XamarinForms.Editors Namespace