Modernizing Your Windows Applications with the Windows App SDK and WinUI

Book description

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

Product information

  • Title: Modernizing Your Windows Applications with the Windows App SDK and WinUI
  • Author(s): Matteo Pagani, Marc Plogas
  • Release date: April 2022
  • Publisher(s): Packt Publishing
  • ISBN: 9781803235660