How do I handle the Button click event?

Platform: .NET MAUI| Category: Controls

You can handle the Button click event by subscribing to the Button’s Clicked event and providing a handler method.
XAML:

<Button x:Name="button" Text="Click Me" Clicked="button_Clicked"/>

C#

button.Clicked += button_Clicked;

private void MyButton_Clicked(object sender, EventArgs e)
{
    // Handle the button click here
}

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.