ebook img

.NET MAUI Cross-Platform Application Development. Leverage a first-class cross-platform UI framework to build native apps on multiple platforms PDF

400 Pages·2023·4.741 MB·English
by  R. Ye
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview .NET MAUI Cross-Platform Application Development. Leverage a first-class cross-platform UI framework to build native apps on multiple platforms

.NET MAUI Cross-Platform Application Development Leverage a first-class cross-platform UI framework to build native apps on multiple platforms Roger Ye BIRMINGHAM—MUMBAI .NET MAUI Cross-Platform Application Development Copyright © 2023 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Group Product Manager: Rohit Rajkumar Publishing Product Manager: Nitin Nainani Senior Editor: Keagan Carneiro Senior Content Development Editor: Debolina Acharyya Technical Editor: Simran Udasi Copy Editor: Safis Editing Project Coordinator: Sonam Pandey Proofreader: Safis Editing Indexer: Rekha Nair Production Designer: Aparna Bhagat Marketing Coordinator: Nivedita Pandey First published: February 2023 Production reference: 1050123 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-80056-922-5 www.packt.com To my family: my wife Bo Quan and my daughter Yuxin Ye, and the memory of my father and my mother. – Roger Ye Contributors About the author Roger Ye is a software engineering manager who has worked in the software industry for many years. Roger started his career as a software engineer in embedded system development at companies such as Motorola, Emerson, and Intersil. During this period, he wrote two books about embedded system programming, Embedded Programming with Android and Android System Programming. In 2013, Roger joined McAfee as a software engineering manager. He recently started working at EPAM Systems, moving from system programming to application programming. His first book on application programming is on .NET MAUI. I want to thank the team at Packt, who worked very hard with me to keep to schedule. About the reviewers Glenn Stephens is a software developer and product designer, implementing solutions for the mobile-, desktop-, and cloud-centered worlds we all live in. Glenn has worked in many different roles, such as managing director, chief executive officer, solution architect, software development manager, and programmer; has worked in fields spanning high-end security, e-health, education, and finance; and has won several awards along the way. Glenn has a bachelor’s degree in computer science, an MBA with a specialization in e-business, and a Graduate Certificate in Arts in theatre and performance. He considers himself a lifelong learner.   An author, speaker, and product builder, he has been writing code since the 80s, with the musical taste to match. When he’s not working, he enjoys playing the piano, reading, and spending time with his children.   Rohit Vinod Kelkar is an artist, a techie, and an experienced mobile application developer who is enthusiastic about cross-platform mobile application technologies. He has expertise in technologies such as Xamarin, Flutter, native iOS, and .NET as a full stack developer. He was an early adopter of .NET MAUI and works with a community of developers to share updates and blog about the technology. He also shares an interest in consulting and helping products in their initial stages.  Siddharth Singh has over 12 years of software development experience, having worked on a variety of platforms such as Windows, web, and mobile applications. Having worked at Expedia, Adobe, and Salesforce, his experience ranges from COM-/ASP-based legacy apps to React/ASP.NET Core modern applications. While working on Xamarin apps, he developed a passion for the Microsoft cross-platform framework.  He currently works at Microsoft as a senior developer for Azure Data Factory, writing data integration applications. When not at work, you can find him reading about theoretical computer science and artificial general intelligence. Table of Contents Preface xiii Part 1: Exploring .NET MAUI 1 Getting Started with .NET MAUI 3 An overview of cross-platform Using Xamarin for mobile development 9 technologies 3 Xamarin.Forms 10 Native applications 4 Xamarin.Essentials 10 Web applications 4 Moving to .NET MAUI 12 Backend services 4 .NET MAUI Blazor apps 14 Cross-platform technologies 4 Choosing XAML versus Razor in .NET MAUI 15 A comparison of .NET, Java, and JavaScript 5 Development environment setup 15 Exploring the .NET landscape 7 Installing .NET MAUI on Windows 16 .NET Framework 7 Installing .NET MAUI on macOS 17 Mono 7 .NET Core 8 What you will learn in this book 19 .NET Standard and portable class libraries 8 The app that we will build in this book 19 Summary 20 Further reading 20 2 Building Our First .NET MAUI App 21 Technical requirements 21 Setting up a new .NET MAUI project 23 Managing the source code in this book 21 Creating a new project using Visual Studio 23 viii Table of Contents Creating a new project using the dotnet Building and debugging 43 command 27 Windows 44 App startup and lifecycle 27 Android 44 iOS and macOS 45 Lifecycle management 29 Scaffolding a Model-View- Configuring the resources 36 ViewModel project 47 App icon 37 Migrating and reusing a Shell template from Splash screen 37 Xamarin.Forms 49 Setting custom font icons 38 Visual Studio project template 54 Summary 56 3 User Interface Design with XAML 57 Technical requirements 58 Stacked 69 Creating a XAML page 58 Controls in .NET MAUI 70 Layouts in .NET MAUI 71 XAML syntax 60 Navigation in the master-detail UI design 74 Element 60 Attribute 62 Supporting multiple languages – XML namespaces and XAML namespaces 62 localization 81 Creating a .resx file 81 XAML markup extensions 66 Localizing text 83 Master-detail UI design 67 Summary 85 Side-by-side 69 Further reading 86 4 Exploring MVVM and Data Binding 87 Technical requirements 87 Improving the data model and service 98 Understanding MVVM and MVC 88 KPCLib 99 MVVM in PassXYZ.Vault 89 PassXYZLib 102 Updating the model 103 Data binding 90 Updating the service 103 Binding mode 94 Changing notifications in viewmodels 96 Table of Contents ix Binding to collections 104 Further reading 111 Summary 111 5 Navigation using .NET MAUI Shell and NavigationPage 113 Technical requirements 113 Tabs 122 Implementing navigation 114 Shell navigation 125 INavigation interface and NavigationPage 114 Improving our model 133 Using the navigation stack 115 Understanding the data model and its services 134 Manipulating the navigation stack 116 Improving the login process 137 Using Shell 117 The Command interface 140 Flyout 119 Summary 143 6 Introducing Dependency Injection and Platform-Specific Services 145 Technical requirements 145 Using built-in MS.DI DI service 151 A quick review of design principles 146 Connecting to the database 160 Exploring types of design principles 146 Initializing the database 162 Using design principles 147 Performing CRUD operations 163 Using DI 149 Summary 172 Dependency Service 149 Further reading 172 Part 2: Implementing .NET MAUI Blazor 7 Introducing Blazor Hybrid App Development 175 Technical requirements 175 Creating a new .NET MAUI Blazor What is Blazor? 176 project 182 Learning about Blazor Server 176 Generating a .NET MAUI Blazor project with the dotnet command line 183 Understanding Blazor Wasm 177 Exploring Blazor Hybrid 179

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.