NET MAUI Projects A guide to building applications for Windows, macOS, Android, and iOS2025 (Sivaraj Ambat)(Z-Library)
C/C++/C#Author:Sivaraj Ambat
No description
AI Reading Assistant
Summary and highlights from this book's index; jump to passages in the text
Tags
Support Statistics
¥.00 ·
0times
Text Preview (First 20 pages)
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
(This page has no text content)
Page
2
(This page has no text content)
Page
3
.NET MAUI Projects A guide to building applications for Windows, macOS, Android, and iOS Sivaraj Ambat www.bpbonline.com
Page
4
First Edition 2025 Copyright © BPB Publications, India ISBN: 978-93-65899-924 All Rights Reserved. No part of this publication may be reproduced, distributed or transmitted in any form or by any means or stored in a database or retrieval system, without the prior written permission of the publisher with the exception to the program listings which may be entered, stored and executed in a computer system, but they can not be reproduced by the means of publication, photocopy, recording, or by any electronic and mechanical means. LIMITS OF LIABILITY AND DISCLAIMER OF WARRANTY The information contained in this book is true to correct and the best of author’s and publisher’s knowledge. The author has made every effort to ensure the accuracy of these publications, but publisher cannot be held responsible for any loss or damage arising from any information in this book. All trademarks referred to in the book are acknowledged as properties of their respective owners but BPB Publications cannot guarantee the accuracy of this information. www.bpbonline.com
Page
5
Dedicated to My family
Page
6
About the Author Sivaraj Ambat is a seasoned software professional with expertise in web, mobile and desktop app development, cloud technologies, and artificial intelligence. With over 30 years of experience across multiple industries, he has worked in sectors such as instrumentation, industrial automation, software development, and education. Sivaraj began his career working on industrial embedded systems and robotics, focusing on automation solutions in the textile industry before transitioning into software development and training. Over the years, he has built extensive experience in developing software across a range of platforms, including web, mobile and desktop. He possesses deep expertise in a variety of programming languages, frameworks, and tools, and consistently keeps up with the latest industry trends and technological advancements. A recipient of the 2016 Top 20 Emerging Leaders award from Training Magazine and Senior Fellowship Award from his previous employer, Sivaraj has made significant contributions to the field of software development. He has also authored and reviewed several books and articles and frequently delivers talks on a wide range of topics related to software development.
Page
7
About the Reviewer Aleksei Starkov is a software engineer specializing in .NET, Xamarin, and .NET MAUI technologies, with extensive experience in building advanced cross-platform mobile applications and frameworks. Over the years, Aleksei has worked with a diverse range of companies, from Agile startups to large-scale enterprises, contributing to innovative, high-quality projects with millions of users that leverage modern technologies. Aleksei is also the author of Learning .NET MAUI: Unlock the Potential of .NET MAUI for Cross-Platform App Development, a comprehensive resource designed to help developers understand .NET MAUI and learn how to develop modern cross-platform production-oriented applications. As a technical reviewer, Aleksei brings his extensive real-world expertise and keen attention to detail, offering valuable insights to help ensure technical content is accurate, practical, and useful for its audience. With his deep knowledge of cross-platform development and his passion for empowering developers, Aleksei continues to make a meaningful impact in the field of mobile application development. His contributions help both individuals and teams to unlock the full potential of .NET MAUI.
Page
8
Acknowledgement I want to express my heartfelt gratitude to everyone who played a role in the completion of this book. First and foremost, I am deeply thankful to my family, friends, and colleagues at DXC Technology for their unwavering support and encouragement throughout this journey. Their encouragement and belief in me have been a constant source of motivation. I also want to express my deep gratitude to my managers for their unwavering encouragement and support. Vidya Gothe, Director - Global Talent Transformation at DXC Technology, has been an incredible source of motivation, always encouraging and supporting me to develop my technical expertise further and inspiring me to pursue writing. I would also like to thank Prabhakar Kanagarajan, Director - Applications at DXC Technology, whose mentorship and encouragement played a valuable role in shaping my skills and providing invaluable guidance throughout my professional journey. Their belief in my abilities has been a constant source of strength and has contributed greatly to the successful completion of this book. I am profoundly grateful to BPB Publications for their expertise and support in bringing this book to life. Their guidance was invaluable in navigating the complexities of the publishing process.
Page
9
My sincere appreciation goes to the reviewers, technical experts, and editors who provided valuable feedback and helped refine the manuscript. Their insights and suggestions have significantly enhanced the quality of the book. Lastly, I want to thank the readers who have shown interest in this book. Your support and enthusiasm mean a great deal to me.
Page
10
Preface In today's rapidly advancing technological landscape, the ability to develop cross-platform applications is becoming increasingly important for developers. .NET MAUI Projects is designed to introduce you to the world of cross-platform app development using .NET MAUI, a powerful and flexible framework for building mobile applications at no cost. This book is structured to guide you step-by-step, assuming no prior knowledge of .NET MAUI or mobile app development. The first five chapters lay the foundation, beginning with an introduction to cross-platform app development and .NET MAUI, followed by setting up your development environment. We then dive into the core programming languages used in .NET MAUI development - C# and XAML - ensuring that you are equipped with the necessary skills to develop apps. The remaining five chapters focus on hands-on projects, providing detailed, step-by-step guidance on how to build real-world applications. By the end of these projects, you will not only have developed several apps but you will also be well-equipped to create your own cross-platform applications and take your skills to the next level. This book is written for absolute beginners, whether you are a student, a working professional seeking to learn this skill, or simply an enthusiast eager to learn. Through clear explanations, practical examples, and accessible language, I aim to make .NET MAUI app development approachable and engaging.
Page
11
I hope that this book will serve as a valuable tool in your journey to becoming proficient in building cross-platform mobile applications. With the skills gained from these chapters, you will be well on your way to creating versatile apps for Windows, MacOS, Android and iOS, opening up new opportunities in the world of app development. Chapter 1: Introduction to Cross-platform Application Development - In this chapter, we will discuss the basics of cross-platform application development. We will start by understanding the need for cross-platform app development and the problems that it helps address. We will discuss the advantages and limitations of cross-platform app development and why it has emerged as a preferred choice for many developers and organizations, examining its advantages, such as code reusability, faster time-to-market, and broader audience reach. Then, we will explore various cross-platform development frameworks and tools available for developers. We will also discuss the impact of emerging technologies on cross-platform app development and its future. Whether you are a seasoned developer seeking to broaden your skill set or a newcomer eager to explore the possibilities of cross-platform development, this chapter offers a comprehensive roadmap to navigate the exciting and ever-evolving landscape of multi-platform application development. Chapter 2: Overview of .NET MAUI - In this chapter, we will begin with a high-level overview of .NET MAUI, exploring its underlying architecture and the key principles that drive its functionality. We will gain an understanding of how .NET MAUI works under the hood (meaning we are going to be looking at the internal workings of .NET MAUI to understand how it functions at an architectural level) and how it empowers developers to leverage its capabilities effectively.
Page
12
Additionally, we will cover a whirlwind tour of the common application programming interfaces (APIs) provided by .NET MAUI, which help developers create dynamic and responsive cross-platform UIs. This chapter will provide a foundation for the readers to understand the flexibility and versatility inherent in .NET MAUI, which will help while developing apps in the later chapters of this book. Furthermore, we will look into the evolution of .NET MAUI from its predecessor, Xamarin. Understanding this transition is crucial for developers looking to migrate their existing Xamarin apps to .NET MAUI seamlessly. We will look into the migration process and the benefits of transitioning to .NET MAUI. Chapter 3: Development Environment Setup - In this chapter, we will also guide you through configuring your development environment to ensure optimal results. Since .NET MAUI is primarily focused on cross-platform development, our main focus will be on setting up your development environment on the Windows operating system. We will also discuss the additional steps required for configuring your Android development environment, which is crucial for testing and deployment. Chapter 4: A Crash Course in C# - This chapter gives a concise and focused introduction to C# designed to equip beginners with the essential knowledge needed to follow the chapters ahead in this book. While this chapter does not provide an exhaustive coverage of the C# language, it serves as a vital primer to ensure that readers, especially those new to C# programming, can comfortably follow and comprehend subsequent discussions. For those seeking in- depth exploration, this publisher offers comprehensive books dedicated to the topic in detail.
Page
13
Chapter 5: Introduction to XAML - In a .NET MAUI app, the user interface (UI) is basically constructed as a tree of objects. The UI is generally created using a markup language instead of C#. This markup language is an XML- based language and is called eXtensible Application Markup Language (XAML). The markup defines the .NET MAUI classes and property values. At runtime, the XAML is parsed and the objects are instantiated and initialized. Chapter 6: Project-1: Color Picker - In this chapter, we will develop a Color Picker using the concepts we have learned so far. A Color Picker, also called RGB Color Mixer, is an essential tool for graphic designers, artists, and developers who need to select colors for their application. It is found in various graphic design software, image editing applications, and web development tools. The Color Picker allows users to adjust the values of red, green, and blue color components individually or in combination to create desired colors. Chapter 7: Project-2: Tip Calculator - In this chapter, you will be introduced to creating a Tip Calculator. A Tip Calculator is a tool or app that helps you figure out how much tip to leave after having food at a restaurant. The tip amount varies depending on the country and cultural norms. In many countries, it is customary to leave a tip of around 15% to 20% of the total bill at restaurants. However, some places may have different tipping customs, and some people may choose to leave more or less than the usual percentage based on the quality of service or personal preferences. Also, when dining in a group, it is common to split the total bill, including the tip, equally among all the individuals to ensure a fair distribution of expenses. This way, everyone contributes their share, making it easier to handle the bill and the tip without any confusion or inconvenience. In this chapter, you will learn how to build a
Page
14
Tip Calculator that will allow users to enter the bill amount, select the desired tip percentage, and the number of people who will split the bill. It will help you instantly calculate the tip amount and the split amount for each user from the total bill amount. Chapter 8: Project-3: BMI Calculator - A Body Mass Index (BMI) calculator is a tool or app used to assess an individual’s body weight in relation to their height. It serves as a basic indicator of whether a person’s weight falls within a healthy range or deviates from it. BMI is widely used in healthcare, fitness, and wellness programs to provide a simple yet informative snapshot of one’s health. The app that we will build in this chapter is not an exhaustive BMI calculator catering to all age groups but rather a simplified version aimed at showcasing key concepts of .NET MAUI. It demonstrates the fundamental functionalities of a BMI calculator, offering users an interactive way to calculate their BMI and receive a basic understanding of their weight status. Chapter 9: Project-4: Unit Converter - A Unit Converter is an invaluable tool that simplifies the conversion of measurements from one unit to another. Doing these conversations manually can become complex, even using a calculator. Unit converters are especially useful for students and a wide range of professionals in various fields who must perform unit conversions as a part of their day-to-day work. In this chapter, we will develop a Unit Converter app that will help users convert values swiftly and accurately among diverse units of measurement related to length, weight, volume, area, temperature, and time. The focus will be on understanding how to use .NET MAUI to develop such an app and not on applying best practices using design patterns. The application structure is intentionally kept simple so that a beginner can also follow it easily. Advanced
Page
15
readers might want to implement it using the Model-View- ViewModel (MVVM) pattern, which provides the benefit of separating the concerns, making the code more maintainable and promotes, and promoting testability. That are beyond our control. Chapter 10: Project-5: Weather App - Weather is one such aspect that affects our lives in many ways. It decides what we do, wear, carry, and how we travel. A weather app is, therefore, a trusted companion in helping us navigate different weather conditions and ensure that our lives are not affected. Besides knowing about the weather and the forecast, the weather app provides an excellent learning opportunity, as it involves some of the advanced skills interfacing with REST API, parsing data, and presenting it in a user-friendly format. In this chapter, we will develop a simple weather app that will allow the user to enter the name of a place and find out the weather, particularly the current temperature and type of weather, and know the weather forecast for the next 7 days, including max and min. temperature. In the process, we will learn how to work with REST API and parse the data. We will also learn how to use the MVVM architectural pattern in application development.
Page
16
Code Bundle and Coloured Images Please follow the link to download the Code Bundle and the Coloured Images of the book: https://rebrand.ly/46df18 The code bundle for the book is also hosted on GitHub at https://github.com/bpbpublications/.NET-MAUI- Projects. In case there’s an update to the code, it will be updated on the existing GitHub repository. We have code bundles from our rich catalogue of books and videos available at https://github.com/bpbpublications. Check them out! Errata We take immense pride in our work at BPB Publications and follow best practices to ensure the accuracy of our content to provide with an indulging reading experience to our subscribers. Our readers are our mirrors, and we use their inputs to reflect and improve upon human errors, if any, that may have occurred during the publishing processes involved. To let us maintain the quality and help us reach out to any readers who might be having difficulties due to any unforeseen errors, please write to us at : errata@bpbonline.com
Page
17
Your support, suggestions and feedbacks are highly appreciated by the BPB Publications’ Family. Did you know that BPB offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.bpbonline.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at : business@bpbonline.com for more details. At www.bpbonline.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on BPB books and eBooks. Piracy If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at business@bpbonline.com with a link to the material. If you are interested in becoming an author If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit www.bpbonline.com. We have worked with thousands of developers and tech professionals, just like you, to help them share their insights with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Reviews Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions. We at BPB can understand what you think about our products, and our authors can see your feedback on their book. Thank you! For more information about BPB, please visit www.bpbonline.com. Join our book’s Discord space Join the book’s Discord Workspace for Latest updates, Offers, Tech happenings around the world, New Release and Sessions with the Authors:
Page
18
https://discord.bpbonline.com
Page
19
Table of Contents 1. Introduction to Cross-platform Application Development Introduction Structure Objectives Introducing cross-platform app development Apps versus. websites App development approaches Pros and cons of cross-platform app development Popular development frameworks and technologies React Native Flutter NativeScript Uno Platform Avalonia .NET MAUI Emerging technologies and cross-platform app development Conclusion Points to remember 2. Overview of .NET MAUI Introduction
Page
20
Structure Objectives Introduction to .NET MAUI Supported platforms Understanding how NET MAUI API works .NET MAUI app anatomy Pages, Layouts and Views Pages Layouts Views Evolution of NET MAUI from Xamarin.Forms Migration from Xamarin.Forms Manual migration Assisted migration using .NET upgrade assistant Platform integration Conclusion Points to remember 3. Development Environment Setup Introduction Structure Objectives Installation of Visual Studio IDE Testing the environment setup Debugging on Windows Debugging on Android Emulator Debugging on Android devices iOS device provisioning
Loading comments...
Reply to Comment
Edit Comment