A Button is a .NET MAUI control that presents an actionable user-interface element. Users tap it to start work such as logging in or saving a stock count. section 8.1.1 section 9.5.3
Connect a Button either to a Clicked event handler in code-behind or to a command exposed by a ViewModel. The first approach handles a login tap and delegates authentication; the second binds an “Add count” action to MVVM logic. section 8.1.1 section 9.5.3
Login and inventory actions
A login page places a Button beneath the app label and disables it while an asynchronous authentication service runs. After successful login, the page is removed from the modal navigation stack. On the inventory page, a Button with Text="Add count" binds Command="{Binding AddCountCommand}" to save the current Stepper value. section 8.1.1 section 9.5.3
Listing 8.1 The updated LoginPage.xaml
<?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="MauiStockTake.UI.Pages.LoginPage"
Title="LoginPage">
<Grid>
<FlexLayout JustifyContent="SpaceAround"
Direction="Column" #1
AlignItems="Center" #2
HorizontalOptions="Center"
VerticalOptions="Center">
<Image Source="surfshack_logo.jpeg"
WidthRequest="200"
HeightRequest="200"
HorizontalOptions="Center"
VerticalOptions="Center">
<Image.Clip>
<EllipseGeometry Center="100,100"
RadiusX="100"
RadiusY="100"/>
</Image.Clip>
</Image>
<Label Text="MauiStockTake"
FontSize="Title"
VerticalOptions="Center"
HorizontalOptions="Center" />
<Button Text="Login"
HorizontalOptions="Center"
VerticalOptions="Center"
Clicked="LoginButton_Clicked"
x:Name="LoginButton"/>
</FlexLayout>
<ActivityIndicator x:Name="LoggingIn"
IsRunning="True"
IsVisible="false"/>
</Grid>
</ContentPage>
Inspect the LoginPage XAML to see Button placement, text, and Clicked-event wiring alongside the surrounding layout. section 8.1.1







