Learn WinUI 3.0 - Alvin Ashcraft - E-Book

Learn WinUI 3.0 E-Book

Alvin Ashcraft

0,0
39,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

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.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 410

Veröffentlichungsjahr: 2021

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Learn WinUI 3.0

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

Alvin Ashcraft

BIRMINGHAM—MUMBAI

Learn WinUI 3.0

Copyright © 2021 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: Aaron Lazar

Publishing Product Manager: Denim Pinto

Senior Editor: Nitee Shetty

Content Development Editor: Ruvika Rao

Technical Editor: Rashmi Subhash Choudhari

Copy Editor: Safis Editing

Project Coordinator: Deeksha Thakkar

Proofreader: Safis Editing

Indexer: Priyanka Dhadke

Production Designer: Alishon Mendonca

First published: March 2021

Production reference: 1260321

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham

B3 2PB, UK.

ISBN 978-1-80020-866-7

www.packt.com

To my wife, Stelene, and to my three daughters, Anna, Luci, and Rubi, for their patience and for supporting me through the writing process. Thank you to the WinUI development team for your openness and communication with the Windows developer community as WinUI 3 evolved and matured.

Contributors

About the author

Alvin Ashcraft is a software engineer and developer community champion with over 25 years of experience in software development. Working primarily with Microsoft Windows, web, and cloud technologies, his career has focused primarily on the healthcare industry. He has been awarded as a Microsoft MVP 11 times, most recently as a Windows Dev MVP.

Alvin works in the Philadelphia area for Allscripts, a global healthcare software company, as a principal software engineer. He is also a board member of the TechBash Foundation, where he helps organize the annual TechBash developer conference. He has previously worked for companies such as Oracle, Genzeon, CSC, and ITG Pathfinders.

Originally from the Allentown, PA area, Alvin currently resides in West Grove, PA with his wife and three daughters.

I want to thank the people who have been close to me and supported me, especially my wife, Stelene, and my three daughters.

About the reviewer

Nick Randolph currently runs Built to Roam, which focuses on building rich mobile applications. Nick has been identified as a Microsoft MVP in recognition of his work with and expertise in Microsoft application platforms.

Nick has been invited to present at a variety of events, including Tech Ed and Ignite Australia & NZ, DDD, NDC, and local user groups. He has also authored multiple books on Visual Studio and Windows development and helped judge multiple world finals for the Imagine Cup. Nick has worked on numerous mobile applications and has helped hundreds of developers build their own mobile applications. Nick has been involved with applications for well-known brands such as Domain.com.au, ninemsn, AFL, NRL, Qantas, JB Hi-Fi, NAB, Stan, and Boost Juice.

Table of Contents

Preface

Section 1: Introduction to WinUI and Windows Applications

Chapter 1: Introduction to WinUI

Technical requirements

Before UWP – Windows 8 XAML applications

Windows application UI design

Windows Runtime (WinRT)

User backlash and the path forward to Windows 10

Windows 10 and UWP application development

Language choice with UWP development

Lifting app restrictions

UWP backward compatibility

What is XAML?

Creating an adaptive UI for any device

Powerful data binding

Styling your UI with XAML

Separating presentation from business logic

What is WinUI?

The first WinUI release

The road to WinUI 3.0

What's new in WinUI 3.0?

Goodbye UWP?

New features for WinUI 3.0

Project Reunion and WinUI

WinUI compared to other Windows development frameworks

WinUI versus UWP

WinUI versus WPF

WinUI versus Windows Forms (WinForms)

Summary

Questions

Chapter 2: Configuring the Development Environment and Creating the Project

Technical requirements

Installing Visual Studio and Windows development workloads

Adding the WinUI app templates

Introducing the application idea

Reviewing the application features

WinUI in UWP versus WinUI in Desktop projects

Creating your first WinUI project

Anatomy of a WinUI in UWP project

Reviewing App.xaml

Reviewing App.xaml.cs

Reviewing MainPage.xaml

Reviewing MainPage.xaml.cs

Reviewing the project references

Reviewing the project properties

XAML basics

Building the model

Creating sample data

Building the initial UI

Completing the data-binding initialization

Creating the DataTemplate and binding the UI

Understanding WinUI and UWP

Understanding the UWP app model

Working with WinUI controls, properties, and events

Adding a ListView header

Creating the ComboBox filter

Adding a new item button

Summary

Questions

Chapter 3: MVVM for Maintainability and Testability

Technical requirements

Understanding MVVM

MVVM – the big picture

MVVM libraries for WinUI

Windows Community Toolkit MVVM library

Prism Library

MVVMCross

Choosing a framework for WinUI applications

Understanding data binding in WinUI

What are markup extensions?

Binding markup extension

x:Bind markup extension

Updating View data with INotifyPropertyChanged

Updating collection data with INotifyCollectionChanged

Implementing MVVM in WinUI applications

Working with events and commands

Implementing ICommand

Using commands in the ViewModel

Updating the View

Choosing a unit test framework

Summary

Questions

Chapter 4: Advanced MVVM Concepts

Technical requirements

Understanding the basics of DI

Using DI with ViewModel classes

Leveraging x:Bind with events

Page navigation with MVVM and DI

Adding ItemDetailsPage

Adding new interfaces and services

Creating a navigation service

Creating a data service

Increasing maintainability by consuming services

Handling parameters in ItemDetailsPage

Creating the ItemDetailsViewModel class

Summary

Questions

Chapter 5: Exploring WinUI Controls

Technical requirements

Understanding what WinUI offers developers

Animated visual player (Lottie)

Navigation view

Parallax view

Rating control

Two-pane view

Exploring the XAML Controls Gallery Windows app

Learning about the ScrollViewer control

Reviewing what's new in WinUI 3.0

Backward compatibility

Visual Studio tooling

Input validation

A new WebView

Exploring the XamlDirect APIs for middleware authors

Adding some new controls to the project

Using the SplitButton control

Adding a TeachingTip to the save button

Summary

Questions

Further reading

Chapter 6: Leveraging Data and Services

Technical requirements

Managing application state with app life cycle events

Exploring Windows application life cycle events

Life cycle events of WinUI applications

Creating a SQLite data store

What is SQLite?

Adding SQLite to DataService

Leveraging a Micro ORM to simplify data access

Adding Dapper to the project

Updating the data service's initialization

Retrieving data via services

Performing data validation with MVVM

Summary

Questions

Section 2: Extending WinUI and Modernizing Applications

Chapter 7: Fluent Design System for Windows Applications

Technical requirements

What is the Fluent Design System?

Exploring Fluent Design for Windows

Controls

Patterns

Layout

Input

Style

Incorporating Fluent Design in WinUI applications

Updating the title bar

Changing the style of MainPage

Changing the style of ItemDetailsPage

Using the Fluent XAML Theme Editor

Colors

Shapes

Using the UWP Resources Gallery

Design resources and toolkits for Fluent Design

Summary

Questions

Chapter 8: Building WinUI Apps with .NET 5

Technical requirements

Creating a WinUI project with .NET 5

What is WinUI in Desktop?

Creating a new WinUI in Desktop project

Exploring the Desktop project structure

Adding the WebView2 control

Exploring the Packaging project

Visual assets in the Manifest Designer

Referencing .NET 5 Libraries from your project

Sharing the .NET 5 library with a WPF application

Creating a WinUI control library

Summary

Questions

Chapter 9: Enhancing Applications with the Windows Community Toolkit

Technical requirements

Introducing the WCT

Origins of the WCT

Reviewing recent toolkit releases

Exploring the Windows Community Toolkit Sample App

Installing and launching the sample app

Controls

WPF and WinForms controls

Using controls from the toolkit

Creating the WinUI in Desktop project

Referencing the WCT packages

Adding data to the DataGrid

Adding controls to the MainWindow

Exploring the toolkit's helpers, services, and extensions

Helpers

Services

MVVM

Extensions

Summary

Questions

Chapter 10: Modernizing Existing Win32 Applications with XAML Islands

Technical requirements

What is XAML Islands?

Modernizing a WinForms application with XAML Islands

Creating a shared class library project

Creating the WinForms host project

Modernizing a WPF application with XAML Islands

Using the UWP MapControl in WPF

Using the WebViewCompatible browser control in WPF

Working with the WebView2 browser control in WinForms

Summary

Questions

Section 3: Build and Deploy on Windows and Beyond

Chapter 11: Debugging WinUI Applications with Visual Studio

Technical requirements

Debugging in Visual Studio

Debugging local applications

Debugging remote applications

Common XAML layout mistakes

Improving your XAML with static code analysis

Learning to pinpoint data binding errors

Common mistakes in data binding

Using the XAML Binding Failures window

Debugging live data with Live Visual Tree and Live Property Explorer

Coding with XAML Hot Reload

Debugging with Live Visual Tree and Live Property Explorer

Summary

Questions

Chapter 12: Hosting an ASP.NET Core Blazor Application in WinUI

Technical requirements

Getting started with ASP.NET Core and Blazor

Exploring some history of ASP.NET and ASP.NET Core

What is Blazor?

WebAssembly and client-side .NET development

Creating a Blazor Wasm application

Building a simple application for tracking tasks

Exploring Blazor Wasm deployment options

Deployment options for Blazor Wasm projects

Publishing Blazor to Azure Static Web Apps hosting

Pushing the project to GitHub

Creating an Azure Static Web Apps resource

Publishing an application with GitHub Actions

Hosting your Blazor application in the WinUI WebView2

Summary

Questions

Chapter 13: Building, Releasing, and Monitoring Applications with Visual Studio App Center

Technical requirements

Getting started with Visual Studio App Center

Creating an App Center account

Creating your first App Center application

Setting up builds in App Center

Integrating App Center with a GitHub repository

Deploying your application with App Center

Creating early releases of your application or beta testers

Application monitoring and analytics

Instrumenting your code

Gathering and analyzing App Center crash reports

Summary

Questions

Chapter 14: Packaging and Deploying WinUI Applications

Technical requirements

Discovering application packaging and MSIX basics

What is MSIX?

Reviewing MSIX tools and resources

Getting started with application packaging in Visual Studio

Deploying applications with Windows Package Manager

Adding a package to the community repository

Using WinGet for package management

Distributing applications with the Microsoft Store

Preparing a free application for the Microsoft Store

Uploading a package to the Store

Sideloading WinUI applications with MSIX

Creating an MSIX package for sideloading

Sideloading an MSIX package

Summary

Questions

Assessments

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Chapter 10

Chapter 11

Chapter 12

Chapter 13

Chapter 14

Why subscribe?

Other Books You May Enjoy

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 WinUIChapter 2, Configuring the Development Environment and Creating the ProjectChapter 3, MVVM for Maintainability and TestabilityChapter 4, Advanced MVVM ConceptsChapter 5, Exploring WinUI ControlsChapter 6, Leveraging Data and Services