Articles in this section
Category / Section

How to disable .NET MAUI Button (SfButton)?

2 mins read

This article explains how to disable the .NET MAUI Button using the IsEnabled property. This property determines the interaction state of the button. In the following example, the button’s state is updated based on the value toggled by a switch control.

XAML:

    <HorizontalStackLayout VerticalOptions="Center" HorizontalOptions="Center" Spacing="15">
        <Switch x:Name="switch1" Toggled="Switch_Toggled"></Switch>
        <buttons:SfButton x:Name="button"
                          WidthRequest="200"
                          HeightRequest="70"
                          IsEnabled="False"
                          Background="LightGray"
                          Text="Disabled" />
    </HorizontalStackLayout>

C#:

private void Switch_Toggled(object sender, ToggledEventArgs e)
{
    if(switch1.IsToggled) 
    {
        button.IsEnabled = true;
        button.TextColor = Colors.Black;
        button.Text = "Enabled";
        button.Background = Colors.Blue;
    }
    else
    {
        button.IsEnabled = false;
        button.TextColor = Colors.Black;
        button.Text = "Disabled";
        button.Background = Colors.LightGray;
    }
}

Output:

ezgif.com-video-to-gif-converted.gif

Conclusion:
I hope you enjoyed learning how to disable the .NET MAUI Button (SfButton).

Refer to our .NET MAUI Button’s feature tour page for other groundbreaking features. Explore our .NET MAUI Button documentation to understand how to present and manipulate data.

Check out our .NET MAUI components from the License and Downloads page for current customers. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI Button and other .NET MAUI components.

Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied