Button

A Button responds to a tap or click that directs an application to carry out a particular task.

Example


        <StackLayout>

            <Label x:Name="label"
                    Text="Hello"
                    FontSize="Large"
                    VerticalOptions="CenterAndExpand"
                    HorizontalOptions="Center" />
    
            <Button Text="Click Me"
                    VerticalOptions="CenterAndExpand"
                    HorizontalOptions="Center"
                    Clicked="OnButtonClicked" />
    
        </StackLayout>
            

Screen

Code Behind


        public partial class MainPage : ContentPage
        {
        
            public MainPage()
            {
                InitializeComponent();
            }
        
                void OnButtonClicked(object sender, EventArgs args)
            {
                label.Text = "Hello from mauiman";
            }
        }
                        

Download

.NET MAUI