Back to Devexpress

DXButton Class

maui-devexpress-dot-maui-dot-core-b3db921c.md

latest14.5 KB
Original Source

DXButton Class

A button control.

Namespace : DevExpress.Maui.Core

Assembly : DevExpress.Maui.Core.dll

NuGet Package : DevExpress.Maui.Core

Declaration

csharp
[DXLicenseMAUI]
public class DXButton :
    DXButtonBase

The following members return DXButton objects:

Remarks

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

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

ClickedFires when a user taps a DXButtonBase descendant.TapFires when a user taps a DXButtonBase descendant. This event allows you to pass additional event data.TapPressedFires when a user taps a DXButtonBase descendant and a finger is not released.TapReleasedFires when a user taps a DXButtonBase descendant and a finger is released.

Button Types

You can use the ButtonType property to specify one of the following appearance types:

|

Button Type

|

Appearance

| | --- | --- | |

Accent

|

| |

Filled

|

| |

Outlined

|

| |

Text

|

| |

ToolButton

|

|

Visual States

The button has a different appearance in each state and you can use the following properties to customize its colors:

Default

BorderColorGets or sets the border color of the button. This is a bindable property.TextColorGets or sets the text color within the button’s content. This is a bindable property.IconColorGets or sets the icon color within the button’s content. This is a bindable property.

Pressed

PressedBorderColorGets or sets the border color of the button in the pressed state. This is a bindable property.PressedBackgroundColorGets or sets the background color of the button in the pressed state. This is a bindable property.PressedTextColorGets or sets the text color of the button in the pressed state. This is a bindable property.PressedIconColorGets or sets the icon color of the button in the pressed state. This is a bindable property.

Disabled

DisabledBorderColorGets or sets the border color of the button in the disabled state. This is a bindable property.DisabledBackgroundColorGets or sets the background color of the button in the disabled state. This is a bindable property.DisabledTextColorGets or sets the text color of the button in the disabled state. This is a bindable property.DisabledIconColorGets or sets the icon color of the button in the disabled state. This is a bindable property.

Font Settings

FontFamilyGets or sets the button’s text font. This is a bindable property.FontSizeGets or sets the text font size within the button’s content. This is a bindable property.FontAttributesGets or sets whether the button’s text font style is bold, italic, or unmodified. This is a bindable property.FontAutoScalingEnabledGets or sets whether the button’s text reflects font scaling preferences set in the operating system. This is a bindable property.

Icons

IconGets or sets the icon image within the button’s content. This is a bindable property.ShowIconGets or sets whether to show an icon within the button’s content. This is a bindable property.IconAspectGets or sets the icon scale within the button’s content. This is a bindable property.IconColorGets or sets the icon color within the button’s content. This is a bindable property.PressedIconColorGets or sets the icon color of the button in the pressed state. This is a bindable property.DisabledIconColorGets or sets the icon color of the button in the disabled state. This is a bindable property.IconColorizationEnabledGets or sets whether to change the icon color within the button’s content. This is a bindable property.IconHeightGets or sets the icon height within the button’s content. This is a bindable property.IconWidthGets or sets the icon width within the button’s content. This is a bindable property.IconIndentGets or sets the distance between icon and text within the button’s content. This is a bindable property.IconPlacementGets or sets the icon position within the button’s content. This is a bindable property.

Alignment

TextHorizontalAlignmentGets or sets the text horizontal alignment within the button’s content. This is a bindable property.TextVerticalAlignmentGets or sets the text vertical alignment within the button’s content. This is a bindable property.VerticalContentAlignmentGets or sets the vertical alignment of the button’s content (icon and text). This is a bindable property.HorizontalContentAlignmentGets or sets the horizontal alignment of the button’s content (icon and text). This is a bindable property.IconPlacementGets or sets the icon position within the button’s content. This is a bindable property.

Ripple Effects

UseRippleEffectGets or sets whether to show ripple effects when a users taps the button. This is a bindable property.RippleEffectPositionGets or sets whether to show ripple effects in front of button content or behind it. This is a bindable property.

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 clear.png icon file to the Resources/Images folder.

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

You can also handle the Tap event to specify an action that occurs when a user taps a DXButtonBase descendant. The Tap event allows you to pass additional event data.

The following featured scenarios show how you can use the DXButton class:

Expandable Cards with Lists

Cards with Custom Content

Context Menu Actions in Popup

Master-Detail View with BottomSheet Control

Infinite Collection View Scrolling

Display Filtering UI Elements in a BottomSheet

Implements

Show 14 items

INotifyPropertyChanged

IAnimatable

Microsoft.Maui.Controls.ITabStopElement

IViewController

IVisualElementController

IElementController

IGestureController

IGestureRecognizers

IPropertyMapperView

IHotReloadableView

IView

Microsoft.Maui.IFrameworkElement

ITransform

IReplaceableView

Inheritance

Show 16 items

System.Object BindableObject Element NavigableElement VisualElement View DevExpress.Maui.Core.Internal.DXViewElement DevExpress.Maui.Core.Internal.DXViewBaseCore DXViewBase DXBorder DXContentPresenterBase DXContentPresenter DXButtonBase DXButton DXToggleButton

TreeNodeExpandButton

Extension Methods

Yield<DXButton>()

YieldIfNotNull<DXButton>()

See Also

DXButton Members

DevExpress.Maui.Core Namespace