Previous part: Updating an Object in the Local Database in MAUI .NET 9 [GamesCatalog] - Part 11
Step 1. Create the main ContentPage and its ViewModel.

MainVM Code
namespace GamesCatalog.ViewModels
{
public partial class MainPageVM : ViewModelBase
{
}
}
Main. xaml.cs Code
using GamesCatalog.ViewModels;
namespace GamesCatalog.Views
{
public partial class Main : ContentPage
{
public Main(MainVM mainVM)
{
InitializeComponent();
BindingContext = mainVM;
}
}
}
Step 2. Add the shell to the CreateMauiApp() in MauiProgram.

Code
builder.Services.AddTransientWithShellRoute<Main, MainVM>(nameof(Main));
Step 3. Set Main as the main route. For now, let’s also disable the sidebar since we won’t need it yet.

Code
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="GamesCatalog.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:GamesCatalog.Views"
Shell.FlyoutBehavior="Disabled">
<ShellContent
ContentTemplate="{DataTemplate local:Main}"
FlyoutItemIsVisible="False"
Route="MainPage" />
</Shell>
Step 4. In Main. xaml, remove the NavBar and set its structure to Grid.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="GamesCatalog.Views.Main"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:Icons="clr-namespace:GamesCatalog.Resources.Fonts"
Shell.NavBarIsVisible="False">
<Grid VerticalOptions="Fill" x:Name="PageGrid">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
</Grid>
</ContentPage>
Step 4.1. After that, inside the main grid (named PageGrid), we’ll define two parts: the inner body and a button to add games to our list.
<ScrollView>
<Grid VerticalOptions="Fill" x:Name="BodyGrid">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
</Grid>
</ScrollView>
<Button
x:Name="BtnAddGame"
Command="{Binding GoToIGDBResultsCommand}"
Style="{StaticResource BtnAddGame}"
Text="Add Game">
<Button.ImageSource>
<FontImageSource
FontFamily="FontAwesomeIcons"
Glyph="{x:Static Icons:IconFont.Plus}"
Size="30" />
</Button.ImageSource>
</Button>
Step 4.2. Let’s create a local style for this button.

Code
<ContentPage.Resources>
<Style x:Key="BtnAddGame" TargetType="Button">
<Setter Property="Margin" Value="0,0,30,30" />
<Setter Property="BackgroundColor" Value="{StaticResource Success}" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="FontSize" Value="20" />
<Setter Property="HorizontalOptions" Value="End" />
<Setter Property="VerticalOptions" Value="End" />
</Style>
</ContentPage.Resources>
Step 5. In the MainVM, create the command for this button:





Join the conversation! Your thoughts help the community grow.