In this example we are going to see ImageButton Example in MAUI.
1) Add new page and Update code as below.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp1.ImageButtonEXP1"
Title="ImageButtonEXP1">
<VerticalStackLayout>
<ImageButton x:Name="ImgButton" Source="logo.png" Clicked="ImgButton_Clicked"></ImageButton>
</VerticalStackLayout>
</ContentPage>
2) Go to .CS pageand update as below.
namespace MauiApp1;
public partial class ImageButtonEXP1 : ContentPage
{
public ImageButtonEXP1()
{
InitializeComponent();
}
private void ImgButton_Clicked(object sender, EventArgs e)
{
DisplayAlert("Alert", "Clicked on Image Button","Ok");
}
}
Output:
Code in Github: https://github.com/adi501/MAUI
No comments:
Post a Comment