Learn WinUI 3.0
eBook - ePub

Learn WinUI 3.0

Leverage the power of WinUI, the future of native Windows application development

Alvin Ashcraft

Share book
  1. 440 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learn WinUI 3.0

Leverage the power of WinUI, the future of native Windows application development

Alvin Ashcraft

Book details
Book preview
Table of contents
Citations

About This Book

A beginner's guide to building Windows applications with WinUI for UWP and desktop applications

Key Features

  • Create modern Windows 10 applications and gain access to UI controls that were previously limited to UWP applications
  • Discover how to modernize your existing Win32 apps with a modern Windows 10 UI
  • Learn to embed a single page application (SPA) in a WinUI application with a web framework like Blazor

Book Description

WinUI 3.0 takes a whole new approach to delivering Windows UI components and controls, and is able to deliver the same features on more than one version of Windows 10. Learn WinUI 3.0 is a comprehensive introduction to WinUI and Windows apps for anyone who is new to WinUI, Universal Windows Platform (UWP), and XAML applications.

The book begins by helping you get to grips with the latest features in WinUI and shows you how XAML is used in UI development. You'll then set up a new Visual Studio environment and learn how to create a new UWP project. Next, you'll find out how to incorporate the Model-View-ViewModel (MVVM) pattern in a WinUI project and develop unit tests for ViewModel commands. Moving on, you'll cover the Windows Template Studio (WTS) new project wizard and WinUI libraries in a step-by-step way. As you advance, you'll discover how to leverage the Fluent Design system to create beautiful WinUI applications. You'll also explore the contents and capabilities of the Windows Community Toolkit and learn to create a new UWP user control. Toward the end, the book will teach you how to build, debug, unit test, deploy, and monitor apps in production.

By the end of this book, you'll have learned how to build WinUI applications from scratch and modernize existing WPF and WinForms applications using WinUI controls.

What you will learn

  • Get up and running with WinUI and discover how it fits into the landscape of Project Reunion and Windows UI development
  • Build new Windows apps quickly with robust templates
  • Develop testable and maintainable apps using the MVVM pattern
  • Modernize WPF and WinForms applications with WinUI and XAML Islands
  • Discover how to build apps that can target Windows and leverage the power of the web
  • Install the XAML Controls Gallery sample app and explore available WinUI controls

Who this book is for

This book is for anyone who wants to develop Windows applications with a modern user experience (UX). If you are familiar with UWP and WPF and are looking to enhance your knowledge of Windows development and modernize existing apps, you will find this book useful. Hands-on experience with C# and.NET is expected but no prior knowledge of WinUI is required.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Learn WinUI 3.0 an online PDF/ePUB?
Yes, you can access Learn WinUI 3.0 by Alvin Ashcraft in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in C#. We have over one million books available in our catalogue for you to explore.

Information

Year
2021
ISBN
9781800207394
Edition
1

Section 1: Introduction to WinUI and Windows Applications

WinUI 3.0 is Microsoft’s new UI framework for Windows developers. This section will start by exploring the recent history of XAML and Windows UI frameworks and introduce readers to WinUI. Throughout the chapters of this section, you will learn about WinUI concepts by building a simple project from scratch, adding controls and features by following design patterns and best practices. These patterns and practices include the Model-View-ViewModel (MVVM) design pattern, unit testing WinUI projects, and using dependency injection (DI) to inject service dependencies into the application components.
This section includes the following chapters:
  • Chapter 1, Introduction to WinUI
  • Chapter 2, Configuring the Development Environment and Creating the Project
  • Chapter 3, MVVM for Maintainability and Testability
  • Chapter 4, Advanced MVVM Concepts
  • Chapter 5, Exploring WinUI Controls
  • Chapter 6, Leveraging Data and Services

Chapter 1: Introduction to WinUI

WinUI is a set of open source controls and libraries that Windows developers can leverage in their Universal Windows Platform (UWP) and Win32 applications. UWP developers use the Windows software development kit (SDK) to build their applications and are required to select a target SDK version in a project's properties. By extracting the UWP controls and user interface (UI) components from the Windows SDK and releasing them as a set of open source libraries under the name WinUI, Microsoft is able to release versions at a faster cadence than Windows itself (as Windows SDK versions are linked to those of Windows). This separation also enables the controls to be used on older versions of Windows 10. While building UWP and Win32 applications with WinUI is the current recommendation, it is important to learn where WinUI and UWP fit in the larger Windows development landscape.
In this book, you will learn how to build applications for Windows with the WinUI 3.0 libraries. Throughout the course of the book, we will build a real-world application using recommended patterns and practices for Windows application development.
Before we start building our WinUI app, it's important to have a good foundation in Windows client development, the different types of Extensible Application Markup Language (XAML) UI markup, and how WinUI compares to other Windows desktop development frameworks. Therefore, in this first chapter, you will start by learning some background on UWP and WinUI.
In this chapter, we will learn about the following topics:
  • What UWP is and why Microsoft created yet another application framework
  • How XAML can be leveraged to create great UIs on many device sizes and families
  • Why WinUI was created and how it relates to UWP
  • Where WinUI fits in the Windows developer landscape
  • What WinUI 3.0 brings to the table
Don't worry! It won't take very long to cover the background stuff, and it will help provide some context as you start building your WinUI app. In the next chapter, you will get your hands on some code when you create your first WinUI project.

Technical requirements

To follow along with the examples in this chapter, the following software is required:
  • Windows 10 version 1803 or newer. You can find your version of Windows in Settings | About.
  • Visual Studio 2019 version 16.9 or newer with the following workloads: .NET Desktop Development and UWP Development.
  • WinUI 3.0 project templates—at the time of this writing, the templates can be downloaded from Visual Studio Marketplace at https://marketplace.visualstudio.com/items?itemName=Microsoft-WinUI.WinUIProjectTemplates. After WinUI 3.0 is released, the templates will likely be included with Visual Studio.
The source code for this chapter is available on GitHub at this URL: https://github.com/PacktPublishing/-Learn-WinUI-3.0/tree/master/Chapter01.
Note
The WinUI 3.0 site on Microsoft Docs has up-to-date guidance on setting up a developer workstation for WinUI development: https://docs.microsoft.com/en-us/uwp/toolkits/winui3/.

Before UWP – Windows 8 XAML applications

Before UWP applications were launched with Windows 10 in 2015, there were XAML applications for Windows 8 and 8.1. The XAML syntax and many of the application programming interfaces (APIs) were the same, and they were Microsoft's next step in an attempt to achieve universal app development across desktop, mobile, and other platforms (Xbox, mixed reality, and so on). A XAML app could be written for Windows 8 and Windows Phone. These projects would generate separate sets of binaries that could be installed on a PC or a Windows Phone.
These apps had many other limitations that modern UWP apps do not. For instance, they only ran fullscreen, as shown in the following screenshot:
Figure 1.1 – Windows 8 fullscreen app (sourced from Stack Overflow; reproduced under CC BY-SA 4.0 – https://creativecommons.org/licenses/by-sa/4.0/)
Figure 1.1 – Windows 8 fullscreen app (sourced from Stack Overflow; reproduced under CC BY-SA 4.0 – https://creativecommons.org/licenses/by-sa/4.0/)
Many other early restrictions on Windows 8 apps have been lessened or completely removed in UWP app development. Figure 1.2, which follows, documents these changes:
Figure 1.2 – Windows 8 and Windows 10 app comparison table
Figure 1.2 – Windows 8 and Windows 10 app comparison table

Windows application UI desig...

Table of contents