Modernizing Your Windows Applications with the Windows App SDK and WinUI: Expand your desktop apps to support new features and deliver an integrated Windows 11 experience

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Use Windows App SDK and WinUI 3 to take your existing Windows desktop applications to the next level by enabling a modern and accessible UI and integrating the latest Windows features like WinML and Windows Hello

Key Features

  • Improve your apps and enable them to support modern devices with features such as touch screens and responsive UI
  • Integrate your app with the latest Windows innovations using modern tools and the newest C# features
  • Reuse your existing knowledge in .NET, C#, and Visual Studio to create new Windows apps

Book Description

If you're a developer looking to improve and modernize your existing LOB applications to leverage modern Windows features without having to rewrite the entire application from scratch, this book is for you. You'll learn how to modernize your existing Windows Forms, WPF, and UWP applications and enrich them with the latest Windows features.

Starting with sample LOB applications that cover common scenarios, you'll learn the differences between various components and then focus on design features for improved visual aspects like accessibility and responsive layouts.

The book shows you how to enhance your existing applications using Windows App SDK components and various Windows APIs, resulting in deeper integration with the operating system. You'll be taking a closer look at WinML, which enables Windows applications to evaluate machine learning models offline and leverage the power of your machine, or notifications, to engage with your users in a more effective way. You'll also learn how to make your application deployment-ready by distributing it using various platforms like the Microsoft Store or websites.

By the end of this Windows book, you'll be able to create a migration plan for your existing Windows applications and put your knowledge to work by enhancing your application with new features and integrating them with the Windows ecosystem.

What you will learn

  • Understand the key concepts of the Windows App SDK and WinUI
  • Integrate new features by creating new applications or by enhancing your existing ones
  • Revamp your app's UI by adopting Fluent Design and new interaction paradigms such as touch and inking
  • Use notifications to engage with your users more effectively
  • Integrate your app with the Windows ecosystem using the Windows App SDK
  • Use WinML to boost your tasks using artificial intelligence
  • Deploy your application in LOB and customer-facing scenarios with MSIX

Who this book is for

This book is for developers who are building Windows applications with Windows Forms, WPF, and UWP and would like to evolve and modernize their applications, but aren't able to rebuild them from scratch. This book focuses on Line-of-Business scenarios. Basic knowledge of Windows app development, .NET/C#, and Visual Studio will help you understand the concepts covered in this book.

Table of Contents

  1. Getting Started with the Windows App SDK and WinUI
  2. The Windows App SDK for a Windows Forms Developer
  3. The Windows App SDK for a WPF Developer
  4. The Windows App SDK for a UWP Developer
  5. Designing Your Application
  6. Building a Future-Proof Architecture
  7. Migrating Your Windows Applications to the Windows App SDK and WinUI
  8. Integrating Your Application with the Windows Ecosystem
  9. Implementing Notifications
  10. Infusing Your Apps with Machine Learning Using WinML
  11. Publishing Your Application
  12. Enabling CI/CD for Your Windows Applications

Author(s): Matteo Pagani, Marc Plogas
Edition: 1
Publisher: Packt Publishing
Year: 2022

Language: English
Pages: 514
Tags: MS Windows; Windows App SDK; WinUI 3; WinML; Windows Hello; MSIX

Cover
Title Page
Copyright
Dedication
Contributors
Table of Contents
Preface
Section 1: Basic Concepts
Chapter 1: Getting Started with the Windows App SDK and WinUI
Technical requirements
A brief history of Windows UI platforms
Introducing the Windows App SDK and WinUI 3.0
The role of the new .NET runtime
Exploring the Windows App SDK
Choosing the right deployment model
Managing the dependency with the Windows App SDK
Packaged apps
Unpackaged apps
Upgrading the Windows App SDK runtime
Creating the first Windows App SDK project
A new packaged WinUI C# application
Using a separate packaging project
A new unpackaged WinUI application
Adding support to an existing application
Building libraries and components
Using a WinUI class library
Using a .NET class library
Summary
Questions
Further reading
Section 2: Modernization Journey
Chapter 2: The Windows App SDK for a Windows Forms Developer
Technical requirements
Introducing XAML
Using namespaces
Customizing controls with properties
Reacting to changes with event handlers
Styling your applications with resources
Sharing a resource with a whole application
Using dictionaries to organize resources
Reusing multiple resources with styles
Understanding animations
Playing an animation
Customizing the template of a control
Using a Universal Windows Platform project
Using the XAML source code
Managing the states of a control
Data binding
Binding with C# objects
Implementing the INotifyPropertyChanged interface
Displaying collections of data with DataTemplates
Creating user controls
Summary
Questions
Chapter 3: The Windows App SDK for a WPF Developer
Technical requirements
Importing XAML namespaces
Binding with x:Bind
Different context
Default binding mode
Using x:Bind to define a DataTemplate
Event binding
Functions
Using the dispatcher
Improving dispatcher usage in asynchronous scenarios
Localizing your applications
Translating the user interface
Handling translation in code
A better way to manage localization
Support localization in a packaged app
Summary
Questions
Chapter 4: The Windows App SDK for a UWP Developer
Technical requirements
Moving to a new namespace
Working with the UI thread
Controlling the application's life cycle
Supporting the application's activation
Supporting multiple activation paths
Application instancing
Supporting advanced redirection scenarios
Managing the application's window
Using the AppWindow class
Performing operations in the background
Summary
Questions
Chapter 5: Designing Your Application
Technical requirements
Creating a responsive layout
Using effective pixels
Adapting the UI
Using the right controls to build a responsive layout
Supporting navigation
Implementing the NavigationMenu control
Handling the navigation
Supporting the page's life cycle
Supporting page transitions
Managing backward navigation
Adding sections to the footer
Displaying a menu at the top
Supporting Windows themes
Forcing a specific theme
Creating animations
Creating animations in C#
Creating animations in XAML
Applying effects and animating them
Connected animations
Using a connected animation in a master-detail scenario
Using animated icons
Exploring the WinUI controls
Summary
Questions
Chapter 6: Building a Future-Proof Architecture
Technical requirements
Learning the basic concepts of the MVVM pattern
Moving a bit deeper into the MVVM pattern
Exploring frameworks and libraries
Supporting actions with commands
Enabling or disabling a command
Making your application easier to evolve
Exchanging messages between different classes
Managing navigation with the MVVM pattern
Navigating to another page
Passing parameters from a ViewModel to another
Summary
Questions
Section 3: Integrating Your App with the Windows Ecosystem
Chapter 7: Migrating Your Windows Applications to the Windows App SDK and WinUI
Technical requirements
Getting an understanding of general migration guidance
Exploring the sample application
Updating your applications to .NET 6
The .NET Portability Analyzer
Upgrading your solution
Migrating a Windows Forms application
Supporting navigation
Migrating from the code-behind approach to the MVVM pattern
Migrating the DataGrid control
Migrating the Details page
Migrating a WPF application
Themes
Migrating a UWP app
Migrating the dispatcher
Activation
Managing the life cycle
Summary
Questions
Chapter 8: Integrating Your Application with the Windows Ecosystem
Technical requirements
Integrating APIs from the Universal Windows Platform
Taking advantage of the Bing Maps service
Introducing biometric authentication
Working with files and folders
Working with folders
Working with files
Using the local storage in packaged apps
Using local storage to store settings
Working with file pickers
Supporting the sharing contract
Building the source app
Building the target app
Integrating web experiences in your desktop application
Adding the WebView2 control to your page
Enabling interactions between the native and web layers
Distributing the WebView2 runtime with your applications
Summary
Questions
Chapter 9: Implementing Notifications
Technical requirements
Sending a notification from a Windows application
Working with toast notifications
Supporting toast notifications in packaged apps
Adding images
Customizing the application's name and the timestamp
Tagging a toast notification
Scheduling a notification
Adding interaction to a notification
Handling activation from a notification
Supporting user input
Displaying a progress bar
Displaying a badge in the taskbar
Implementing push notifications
Implementing the backend
Limitations of the current implementation
Summary
Questions
Chapter 10: Infusing Your Apps with Machine Learning Using WinML
Technical requirements
A brief introduction to ONNX and WinML
Evaluating an ONNX model with WinML
Loading the ONNX model
Loading the labels
Preparing the model input
Performing the evaluation
Sorting the results
Putting everything together
Training and using your own machine learning model
Training the model
Testing the model
Exporting the model
Summary
Questions
Section 4: Distributing Your Application
Chapter 11: Publishing Your Application
Understanding the MSIX packaging technology
Built-in optimizations around network bandwidth and disk space
Deployment flexibility
Tamper protection and signature enforcement
Registry virtualization
Local application data virtualization
The Virtual File System (VFS)
MSIX limitations
The anatomy of an MSIX package
Creating and signing an MSIX package
Choosing a distribution method
Choosing a signing method
Selecting and configuring packages
Signing an MSIX package
Publishing your application to Microsoft Store
Submitting an MSIX packaged application
Submitting an unpackaged application
The certification process
Submitting updates
Deploying your applications from a website using AppInstaller
Generating an AppInstaller file with Visual Studio
Generating an AppInstaller file with AppInstaller File Builder
Deploying an AppInstaller file
Updating an application automatically
Updating an application from code
Supporting updates and repairs
Publishing your application to the Windows Package Manager repository
Creating a manifest for Windows Package Manager
Summary
Questions
Chapter 12: Enabling CI/CD for Your Windows Applications
Technical requirements
Introducing CI/CD pipelines
Building a Windows application in a CI/CD pipeline
Pulling the source code
Adding MSBuild to the system's path
Building the Windows application
Publishing the artifact
Testing the workflow
Supporting versioning
Installing the tool and generating the version number
Setting the version number
Handling signing
Storing the certificate on GitHub
Automating the deployment
Generating the App Installer file
Deploying our Windows application
Improving the deployment story
Summary
Questions
Further reading
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
Index
About Packt
Other Books You May Enjoy
About Packt