Skip to main content

.NET MAUI DXSwitch: Caption

  • 2 minutes to read

The DXSwitch control can display a caption near the switch. Use the Content property to specify the caption.

.NET MAUI DXSwitch - Caption

You can enable the AllowContentTap property to change the DXSwitch state when a user taps the caption.

Specify and Configure a DXSwitch Caption

The following example specifies a caption and changes its color in different states:

.NET MAUI DXSwitch - Caption States

<ContentPage ...
            xmlns:dx="http://schemas.devexpress.com/maui">
        <dx:DXSwitch ... 
            Content="Airplane mode"
            AllowContentTap="True"

            SwitchIndent="15"

            TextColor="Green"
            CheckedTextColor="Purple"
            DisabledTextColor="Gray"
            DisabledCheckedTextColor="Red" /> 
</ContentPage>

Use the following properties to specify the caption and change its color in different states:

Content
Gets or sets the caption of the DXSwitch. This is a bindable property.
AllowContentTap
Gets or sets whether to toggle the DXSwitch when a user taps its caption. This is a bindable property.
SwitchIndent
Gets or sets the gap between the caption and the track within the DXSwitch. This is a bindable property.
TextColor
Gets or sets the caption color of the DXSwitch. This is a bindable property.
CheckedTextColor
Gets or sets the caption color of the DXSwitch in the checked state. This is a bindable property.
DisabledTextColor
Gets or sets the caption color of the DXSwitch in the disabled state. This is a bindable property.
DisabledCheckedTextColor
Gets or sets the caption color of the DXSwitch in disabled and checked states. This is a bindable property.

Track and Caption Positions

Use the SwitchPlacement property to change relative track and caption positions as follows:

.NET MAUI DXSwitch - Track and Caption Positions