liveBook · Manning

Button

As explained in .NET MAUI in Action

Button is a .NET MAUI control that presents an actionable user-interface element.

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

How .NET MAUI in Action covers it

How deep it goes
Shows placement, event and command wiring, asynchronous state handling, and MVVM delegation without detailing Button internals.
Examples
Uses login and Add count Buttons within LoginPage and InputPage workflows.
What it assumes
Assumes basic XAML layout and C# familiarity while demonstrating event handling, commands, binding, and service delegation.
What you can do after
Build it from scratch by placing a Button in XAML and wiring it to an event handler or ViewModel command.
How it connects
Connects Buttons to event handlers, code-behind, authentication services, MVVM, commands, data binding, and navigation.

Also explained in

Compare how 8 books explain button →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET MAUI in Action. The section links point to the parts of the book it draws on.