Skip to main content

2022 | Buch

Getting Started with the Uno Platform and WinUI 3

Hands-On Building of Cross-Platform Desktop, Mobile, and Web Applications That Can Run Anywhere

insite
SUCHEN

Über dieses Buch

Get ready to build applications that can run anywhere using the Uno Platform and WinUI.

Modern application development can be an intimidating and complex topic, especially when you are building cross-platform applications that need to support multiple operating systems and form factors. There are so many options when it comes to frameworks and selecting the right one for your enterprise is critical in delivering a successful product to market. For the developer who has zero experience building apps with Xamarin, UWP, WinUI, or the Uno Platform, this book deconstructs those complex concepts into tangible building blocks so that productivity gains are immediately recognized.

You will start off learning basic concepts and get a bird's-eye view of the enabling technologies to ensure that you feel comfortable with the tools and terminology. From there, you will learn about some of the more popular options in the .NET ecosystem, understand their attributes and shortcomings, and learn why the Uno Platform is ideal for building a cross-platform application that targets Android, iOS, Windows, WASM (Web Assembly), Linux, and MacOS.

Then, you will follow a product release timeline that takes you through building an application, introducing key concepts at every step of the way. Each section of the book is chock full of tips and edge case documentations for the different platforms.

What You Will Learn

Manage multi-targeting solutions: specifically, how to handle the different project headsEffectively write cross-platform software and handle the edge cases of the different platformsUnderstand the fundamentals of working with Uno Platform WinUI appsExplore enterprise-grade application architecture using MVVMUnderstand Dependency Injection and how it applies to application architecture

Who This Book Is For

Developers who understand some basics of C# and object-oriented programming

Inhaltsverzeichnis

Frontmatter
Chapter 1. Introduction to Uno Platform
Abstract
There are many options available when building cross-platform applications in the .NET ecosystem, especially when considering the variety of mobile devices and different form factors available today. Some of the popular options are using Uno Platform, .NET MAUI (Multi-platform App UI), Xamarin.Forms, Avalonia UI, and others. This book is all about Uno Platform development, but each framework has advantages and disadvantages over the others.
Skye Hoefling
Chapter 2. New Project
Abstract
In this book we are going to build a cross-platform app that uses Uno Platform and WinUI 3 as the application framework. Then we will leverage public APIs from OneDrive and the Microsoft Graph. You will learn the basics of user interface development, application architecture, and accessing native APIs as we build our app, at least initially, offline first.
Skye Hoefling
Chapter 3. Your First Page
Abstract
In the previous chapter, we learned about setting up our Uno Platform development environment, and we created our new UnoDrive application using the .NET 6 and WinUI 3 project templates. In this chapter we are going to build the very first page of our application that the user will see, which is the login screen.
Skye Hoefling
Chapter 4. Application Styles
Abstract
In the previous chapter, we built our first page, which is the login page. As we learned our way around the WinUI 3 tools, we added several styles that we are using in multiple controls. It is important to set a standard in your application from the beginning of how you want styles to be configured. If this is not done early on, it will be difficult to go back and do it afterward. In this chapter we will go over different techniques for implementing application-wide reusable styles and how to best manage them depending on the size of your application.
Skye Hoefling
Chapter 5. Platform-Specific Code and XAML
Abstract
Even with all the abstractions in Uno Platform, you will still need to write platform-specific code or XAML. When interacting with native APIs, you will always need to write code for those APIs. In the user interface, there may be spacing issues on controls not lining up just right, and you’ll need to add platform-specific XAML. In this chapter we are going to cover the various techniques of adding platform-specific code and XAML for Uno Platform.
Skye Hoefling
Chapter 6. Master-Detail Menu and Dashboard
Abstract
Our application is going to have a main dashboard where all the operations of the authenticated user occur. You may also refer to this type of page as the main page or an application shell. In our application we will call it the dashboard, which is going to be our first deep dive into layout and menus. In Uno Platform you have several different ways to build your view stack and menus. In this chapter we are going to highlight some of the standard techniques and then build a flyout menu–style dashboard.
Skye Hoefling
Chapter 7. Custom Fonts
Abstract
In the previous chapter, we added a new dashboard menu, which contained a custom header control with buttons in the top-right portion of the page. These buttons had icons that only worked on Windows using either the Windows or WPF target project. That is because all the other platforms do not have the right font files loaded into the projects. In this chapter we are going to finish that work by adding the custom font file and ensuring everything is rendered correctly.
Skye Hoefling
Chapter 8. Model-View-ViewModel (MVVM)
Abstract
In the last few chapters, we have been building our main application dashboard and login page. We are now ready to start architecting our application to support scalable design patterns that separate the user interface code from business rules and code that communicates with the Microsoft Graph for OneDrive APIs.
Skye Hoefling
Chapter 9. Dependency Injection and Logging
Abstract
In the previous chapter, we learned about building our Model-View-ViewModel (MVVM) application architecture and how all the pieces fit together in our application. MVVM applications thrive when they use Dependency Injection, which decouples the deeper business rules from the ViewModels. We are going to continue building up our MVVM library by adding Dependency Injection into it and configure our logging so we can use a simple ILogger interface in any class.
Skye Hoefling
Chapter 10. Application Navigation
Abstract
In our application we have implemented a flyout menu dashboard page to be the main landing page of the application. This required implementing dashboard-specific navigation to update the main content area. If you need a refresher on what we did, refer to Chapter 6. That was an introduction to application navigation but didn’t cover it in detail. In this chapter we will be learning more about navigation in Uno Platform and how to add a navigation service to work in our MVVM architecture.
Skye Hoefling
Chapter 11. Authentication with Azure Active Directory
Abstract
Our application is starting to take shape, and it is time to implement authentication, which will allow our users to log in and connect to their data. When adding authentication to your application, there are many tools at your disposal to choose from such as using a social authentication provider like Facebook or Twitter or using a business authentication provider like Microsoft or Google. Our application will be using the Microsoft authentication provider known as Azure Active Directory (Azure AD). The techniques covered in this chapter apply to users who want to access hosted data available in Microsoft services such as Office 365 or OneDrive. Authentication in other platforms such as Facebook and Google follows similar techniques, but the implementation will vary depending on the API.
Skye Hoefling
Chapter 12. Converters
Abstract
In Chapter 8 we introduced the Model-View-ViewModel application design, which includes the concept of data binding, a technique used to bind public properties from your ViewModel to various properties of a user interface control that resides in the View or page. In many cases the properties exposed by the ViewModel do not match the properties that are to be shown on the user interface control. This is when you would want to consider using a converter.
Skye Hoefling
Chapter 13. Microsoft Graph, Web APIs, and MyFilesPage
Abstract
The Microsoft Graph is the API we are going to use to communicate with Microsoft OneDrive to retrieve files and folders in our UnoDrive application. It is a RESTful API, which you can integrate with using any language, that provides read and write access to many Microsoft services, including OneDrive.
Skye Hoefling
Chapter 14. Microsoft Graph and Dashboard Menu
Abstract
In the previous chapter, we implemented the full-stack solution for retrieving data from OneDrive and displaying it on the MyFilesPage. We are going to take some of those concepts and update the Dashboard menu to include personalized information for the user’s email and name in the left corner.
Skye Hoefling
Chapter 15. Images and GridView
Abstract
Adding images to an application is important to give your product a final customized look and feel. This is true for all applications from a general consumer product to a line-of-business product that is more focused on filling out forms. The images are vital in helping the user navigate through the application and perform their tasks. In this chapter we are going to review the basics of adding images and how to render them on the screen.
Skye Hoefling
Chapter 16. Selectors
Abstract
In Chapter 12 we learned about converters. In this chapter, we will be learning about selectors, which are conceptually very similar but solve a different problem. A selector is used when you are binding a collection to a list control or similar. When displaying multiple items in a list and you need to render the row differently based on the type of data in that row, you will use a selector to determine the correct DataTemplate to render. A selector will run a code block for each item in the collection, which allows us to determine how to render the row.
Skye Hoefling
Chapter 17. OneDrive Navigation
Abstract
In Chapters 13–16, we have been implementing the MyFilesPage that accesses OneDrive files from the user’s account and loads them onto the screen. Currently, the application only allows you to access files in the root OneDrive directory. In this chapter we will learn how to add navigation through the various pages by applying the concepts we have learned so far on MVVM applications.
Skye Hoefling
Chapter 18. Offline Data Access
Abstract
When building a mobile application, there is no guarantee that you will always have a stable Internet connection. It is best to build your application with the expectation that the connection will be severed, and it should seamlessly transition between offline mode and online mode. Since more and more devices are becoming more portable such as hybrid laptops that act as tablets, our applications need to handle this on other platforms than just mobile.
Skye Hoefling
Chapter 19. Complete App
Abstract
In this chapter we will be finishing the UnoDrive application by using concepts we have already learned in the book. By the end of this chapter, you will have a fully functioning application that you can use as an example for your next project. We will be adding more code to complete the Recent Files and Shared Files pages. This includes complete changes for new APIs that invoke the Microsoft Graph. We will be adding code in ViewModels, the service layer, and the data store.
Skye Hoefling
Backmatter
Metadaten
Titel
Getting Started with the Uno Platform and WinUI 3
verfasst von
Skye Hoefling
Copyright-Jahr
2022
Verlag
Apress
Electronic ISBN
978-1-4842-8248-9
Print ISBN
978-1-4842-8247-2
DOI
https://doi.org/10.1007/978-1-4842-8248-9