.NET MAUI Projects - Third Edition

Book description

Harness the powerful features of .NET MAUI, the evolution of Xamarin.Forms, to create multi-platform app projects using location services, the weather API, machine learning, and much more

Key Features

  • Leverage .NET MAUI through real-world projects, from weather apps to real-time multiplayer games with SignalR and Azure Functions
  • Explore the essential features of .NET MAUI such as Shell, CollectionView, and CarouselView
  • Go beyond the basics with advanced topics like machine learning using TensorFlow and ML.NET
  • Purchase of the print or Kindle book includes a free PDF eBook

Book Description

This third edition of .NET MAUI Projects explores the features of .NET MAUI, a lightweight multi-platform development toolkit for building apps with a rich user interface. Updated to cover the latest features of .NET MAUI, including CollectionView and Shell, this book delves into concepts such as machine learning and cloud services.

Starting with an overview of .NET Core and how it works, this book shares tips for choosing the right development environment for planning multi-platform apps. You'll then build your first .NET MAUI app and advance to learning how to use Shell to implement app architecture. Progressing in complexity, the projects guide you through creating apps, ranging from a location tracker and weather map to machine learning and multiplayer games. Further, the book will take you through modern mobile development frameworks such as SQLite, .NET Core, and ML.NET, empowering you to customize your apps for Windows, macOS, Android, and iOS platforms for native-like performance. Engaging examples are woven throughout the book so you can grasp essential concepts by writing code rather than extensive theory.

By the end of this book, you'll be ready to develop your own native apps using .NET MAUI and associated technologies such as .NET Core, Visual Studio 2022, and C#.

What you will learn

  • Set up .NET MAUI to build native apps for multiple platforms using its single project capabilities
  • Understand the core aspects of developing a mobile app, such as layout, UX, and rendering
  • Use custom handlers for platform-specific access
  • Discover how to create custom layouts for your apps with .NET MAUI Shell
  • Implement serverless services in your .NET MAUI apps using Azure SignalR
  • Create a .NET MAUI Blazor application leveraging the power of web technologies
  • Build and train machine learning models using ML.NET and Azure Cognitive Services

Who this book is for

This book is for C# and .NET developers who want to learn .NET MAUI and get started with native .NET Core mobile application development from the ground up. Working knowledge of Visual Studio and C# will help you to get the most out of this book.

Table of contents

  1. .NET MAUI Projects
  2. Foreword
  3. Contributors
  4. About the authors
  5. About the reviewers
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Conventions used
    6. Get in touch
    7. Share your thoughts
    8. Download a free PDF copy of this book
  7. Part 1: Introduction
  8. Chapter 1: Introduction to .NET MAUI
    1. Defining native applications
    2. .NET mobile
      1. Code sharing
      2. Use of existing knowledge
      3. .NET mobile platforms
    3. Exploring the .NET MAUI framework
      1. The architecture of .NET MAUI
      2. Defining a UI using XAML
      3. .NET MAUI versus traditional .NET mobile
    4. Setting up our development machine
      1. Setting up a Mac
      2. Setting up a Windows machine
    5. .NET mobile productivity tooling
      1. Xamarin Hot Restart
      2. Hot Reload
      3. Windows Subsystem for Android
    6. Summary
  9. Chapter 2: Building Our First .NET MAUI App
    1. Technical requirements
    2. Project overview
    3. Setting up the project
      1. Creating the new project
      2. Examining the files
      3. Updating the .NET MAUI packages
    4. Creating a repository and a TodoItem model
      1. Defining a to-do list item
      2. Creating a repository and its interface
      3. Connecting SQLite to persist data
    5. Using MVVM – creating views and ViewModels
      1. Defining a ViewModel base class
      2. Introducing the CommunityToolkit.Mvvm library’s ObservableObject and ObservableProperty
      3. Creating MainViewModel
      4. Creating TodoItemViewModel
      5. Creating the ItemViewModel class
      6. Creating the MainView view
      7. Creating the ItemView view
      8. Wiring up dependency injection
      9. Making the app run
    6. Adding data bindings
      1. Navigating from MainView to ItemView to add a new item
      2. Adding new items to the list
      3. Binding ListView in MainView
      4. Creating a ValueConverter object for the item’s status
      5. Navigating to an item using a command
      6. Marking an item as complete using a command
      7. Creating the filter toggle function using a command
    7. Laying out the contents
      1. Setting an application-wide background color
      2. Laying out the MainView and ListView items
    8. Summary
  10. Chapter 3: Converting a Xamarin.Forms App into .NET MAUI
    1. Technical requirements
    2. Project overview
    3. Migrating into a blank .NET MAUI template
      1. Creating a new Xamarin.Forms app
      2. Creating a new .NET MAUI app
      3. Migrating the MauiMigration app to MyMauiApp
    4. Manual migration overview
      1. Converting the Xamarin.Forms projects from .NET Framework into .NET SDK style
      2. Updating code from Xamarin.Forms to .NET MAUI
      3. Updating any incompatible NuGet packages
      4. Addressing any breaking API changes
      5. Custom renderers and effects
      6. Running the converted app and verifying its functionality
    5. Installing and running .NET Upgrade Assistant
      1. Installing .NET Upgrade Assistant
      2. Preparing to run .NET Upgrade Assistant
      3. Running .NET Upgrade Assistant
    6. Summary
  11. Part 2: Basic Projects
  12. Chapter 4: Building a News App Using .NET MAUI Shell
    1. Technical requirements
    2. Project overview
    3. Building the news app
      1. Setting up the project
      2. Creating the structure of the app
      3. Creating the news service
      4. Wiring up the NewsService class
      5. Handling navigation
    4. Summary
  13. Chapter 5: A Matchmaking App with a Rich UX Using Animations
    1. Technical requirements
    2. Project overview
    3. Creating the matchmaking app
      1. Setting up the project
      2. Creating the Swiper control
      3. Testing the control
      4. Wiring up the Swiper control
    4. Summary
  14. Chapter 6: Building a Photo Gallery App Using CollectionView and CarouselView
    1. Technical requirements
    2. Project overview
    3. Building the photo gallery app
      1. Creating the new project
      2. Importing photos
      3. Creating the gallery view
    4. Summary
  15. Chapter 7: Building a Location Tracking App Using GPS and Maps
    1. Technical requirements
    2. Project overview
    3. Building the MeTracker app
      1. Creating a repository to save the locations of the users
      2. Creating a service for location tracking
      3. Setting up the app logic
      4. Background location tracking on iOS and Mac Catalyst
      5. Background location tracking with Android
      6. Creating a heat map
      7. Creating a custom control for the map
      8. Refreshing the map when the app resumes
    4. Summary
  16. Chapter 8: Building a Weather App for Multiple Form Factors
    1. Technical requirements
    2. Project overview
    3. Building the weather app
      1. Creating models for the weather data
      2. Creating a service to fetch the weather data
      3. Configuring the application platforms so that they use location services
      4. Creating the ViewModel class
      5. Creating the view for tablets and desktop computers
      6. Creating the view for phones
      7. Adding services and ViewModels to dependency injection
      8. Navigating to different views based on the form factor
      9. Handling states with VisualStateManager
    4. Summary
  17. Part 3: Advanced Projects
  18. Chapter 9: Setting Up a Backend for a Game Using Azure Services
    1. Technical requirements
    2. Project overview
      1. An overview of the game
    3. Understanding the different Azure serverless services
      1. Azure SignalR Service
      2. Azure Functions
    4. Building the serverless backend
      1. Creating a SignalR service
      2. Using Azure Functions as an API
    5. Deploying the functions to Azure
    6. Summary
  19. Chapter 10: Building a Real-Time Game
    1. Technical requirements
    2. Project overview
    3. Getting started
      1. An overview of the game
    4. Building the game app
      1. Creating the game services
      2. Creating the Connect page
      3. Creating the Lobby page
      4. Creating the Match page
      5. Testing the completed project
    5. Summary
  20. Chapter 11: Building a Calculator Using .NET MAUI Blazor
    1. Technical requirements
    2. Project overview
    3. What is Blazor?
    4. Creating the calculator app
      1. Setting up the project
      2. Creating the Keypad view
      3. Creating the Compute service
      4. Adding memory functions
      5. Resizing the main window
    5. Summary
  21. Chapter 12: Hot Dog or Not Hot Dog Using Machine Learning
    1. Technical requirements
    2. Machine learning
      1. Azure Cognitive Services – Custom Vision
      2. Core ML
      3. TensorFlow
      4. ML.Net
    3. The project overview
    4. Getting started
    5. Building the Hot Dog or Not Hot Dog application using machine learning
      1. Training a model
      2. Building the app
    6. Summary
  22. Index
    1. Why subscribe?
  23. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Download a free PDF copy of this book

Product information

  • Title: .NET MAUI Projects - Third Edition
  • Author(s): Michael Cummings, Daniel Hindrikes, Johan Karlsson
  • Release date: February 2024
  • Publisher(s): Packt Publishing
  • ISBN: 9781837634910