Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
.NET MAUI Projects - Third Edition

You're reading from  .NET MAUI Projects - Third Edition

Product type Book
Published in Feb 2024
Publisher Packt
ISBN-13 9781837634910
Pages 630 pages
Edition 3rd Edition
Languages
Authors (3):
Michael Cummings Michael Cummings
Profile icon Michael Cummings
Daniel Hindrikes Daniel Hindrikes
Profile icon Daniel Hindrikes
Johan Karlsson Johan Karlsson
Profile icon Johan Karlsson
View More author details

Table of Contents (18) Chapters

Preface 1. Part 1: Introduction
2. Chapter 1: Introduction to .NET MAUI 3. Chapter 2: Building Our First .NET MAUI App 4. Chapter 3: Converting a Xamarin.Forms App into .NET MAUI 5. Part 2: Basic Projects
6. Chapter 4: Building a News App Using .NET MAUI Shell 7. Chapter 5: A Matchmaking App with a Rich UX Using Animations 8. Chapter 6: Building a Photo Gallery App Using CollectionView and CarouselView 9. Chapter 7: Building a Location Tracking App Using GPS and Maps 10. Chapter 8: Building a Weather App for Multiple Form Factors 11. Part 3: Advanced Projects
12. Chapter 9: Setting Up a Backend for a Game Using Azure Services 13. Chapter 10: Building a Real-Time Game 14. Chapter 11: Building a Calculator Using .NET MAUI Blazor 15. Chapter 12: Hot Dog or Not Hot Dog Using Machine Learning 16. Index 17. Other Books You May Enjoy

Building a Photo Gallery App Using CollectionView and CarouselView

In this chapter, we will build an app that shows photos from the camera roll (photo gallery) of a user’s device. The user will also be able to select photos as favorites. We will then look at the different ways to display photos—in carousels and in multi-column grid control. By using the .NET MAUI CarouselView control to display a group of images, the user can swipe through them to view each image. To display a large group of images, we will use the .NET MAUI CollectionView control and vertical scrolling to allow the user to view all the images. By learning how to use these controls, we will be able to use them in a lot of other cases when we build real-world apps.

The following topics will be covered in this chapter:

  • Requesting permissions from the user to access data
  • How to import photos from the iOS and Mac Catalyst photo gallery
  • How to import photos from the Android photo gallery...

Technical requirements

To be able to complete this project, you will need to have Visual Studio for Mac or Windows installed, as well as the necessary .NET MAUI workloads. See Chapter 1, Introduction to .NET MAUI, for more details on how to set up your environment.

To build an iOS app using Visual Studio for your PC, you have to have a Macintosh (Mac) device connected. If you don’t have access to a Mac at all, you can just follow the Android and Windows part of this project.

You can find the full source for the code in this chapter at https://github.com/PacktPublishing/MAUI-Projects-3rd-Edition/.

Project overview

Almost all apps visualize collections of data, and in this chapter, we will focus on two of the .NET MAUI controls that can be used to display data collections—CollectionView and CarouselView. Our app will show the photos that users have on their devices; to do that, we need to create a photo importer for each platform—one for iOS and Mac Catalyst, one for Windows, and one for Android.

The build time for this project is about 60 minutes.

Building the photo gallery app

This project, like all the rest, is a File | New | Project...-style project, which means that we will not be importing any code at all. So, this first section is all about creating the project and setting up the basic project structure.

It’s time to start building the app using the following steps. Let’s begin!

Creating the new project

The first step is to create a new .NET MAUI project:

  1. Open Visual Studio 2022 and select Create a new project:
Figure 6.1 – Visual Studio 2022

Figure 6.1 – Visual Studio 2022

This will open the Create a new project wizard.

  1. In the search field, type in maui and select the .NET MAUI App item from the list:
Figure 6.2 – Create a new project

Figure 6.2 – Create a new project

  1. Click Next.
  2. Complete the next step of the wizard by naming your project. We will be calling our application GalleryApp in this case. Move on to the next dialog box by clicking Next, as shown...

Summary

In this chapter, we focused on photos. We learned how to import photos from the platform-specific photo galleries and how we can display them as a grid using CollectionView and in carousels using CarouselView. This makes it possible for us to build other apps and provides multiple options for presenting data to users, as we can now pick the best method for the situation.

Additionally, we learned about permissions and how to check and request permission to use protected resources in our app.

If you are interested in extending the app even further, try creating a page to view the details of the photo, or to view the photo in full screen by tapping on the photo.

In the next chapter, we will build an app using location services and look at how to visualize location data on a map.

lock icon The rest of the chapter is locked
You have been reading a chapter from
.NET MAUI Projects - Third Edition
Published in: Feb 2024 Publisher: Packt ISBN-13: 9781837634910
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}