ImageButton

A ImageButton is a control that displays an image on a button and responds to a tap or click to carry out an action. It defines a Source property to be set to an image that is either a file, a URI, a resource, or a stream.


        <StackLayout>
            <Label Text="ImageButton"
                    FontSize="50"
                    FontAttributes="Bold"
                    HorizontalOptions="Center" />
            <ImageButton Source="redappleisolated.jpg"
                            HorizontalOptions="Center"
                            VerticalOptions="CenterAndExpand" 
                            Clicked="OnImageButtonClicked" />                            
        </StackLayout>
                

Tip

File names must be lowercase, start and end with a letter character, and contain only alphanumeric characters or underscores.

Invalid: red-apple-isolated.jpg

Valid: redappleisolated.jpg

Code Behind


        void OnImageButtonClicked(object sender, EventArgs e)
        {
            imageButton.Text = "Hello ImageButton";
        }
                

Download

.NET MAUI