0%

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.

Table of Contents

  1. Learn WinUI 3.0
  2. Contributors
  3. About the author
  4. About the reviewer
  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. Download the color images
    6. Conventions used
    7. Get in touch
    8. Reviews
  6. Section 1: Introduction to WinUI and Windows Applications
  7. Chapter 1: Introduction to WinUI
    1. Technical requirements
    2. Before UWP – Windows 8 XAML applications
    3. Windows application UI design
    4. Windows Runtime (WinRT)
    5. User backlash and the path forward to Windows 10
    6. Windows 10 and UWP application development
    7. Language choice with UWP development
    8. Lifting app restrictions
    9. UWP backward compatibility
    10. What is XAML?
    11. Creating an adaptive UI for any device
    12. Powerful data binding
    13. Styling your UI with XAML
    14. Separating presentation from business logic
    15. What is WinUI?
    16. The first WinUI release
    17. The road to WinUI 3.0
    18. What's new in WinUI 3.0?
    19. Goodbye UWP?
    20. New features for WinUI 3.0
    21. Project Reunion and WinUI
    22. WinUI compared to other Windows development frameworks
    23. WinUI versus UWP
    24. WinUI versus WPF
    25. WinUI versus Windows Forms (WinForms)
    26. Summary
    27. Questions
  8. Chapter 2: Configuring the Development Environment and Creating the Project
    1. Technical requirements
    2. Installing Visual Studio and Windows development workloads
    3. Adding the WinUI app templates
    4. Introducing the application idea
    5. Reviewing the application features
    6. WinUI in UWP versus WinUI in Desktop projects
    7. Creating your first WinUI project
    8. Anatomy of a WinUI in UWP project
    9. Reviewing App.xaml
    10. Reviewing App.xaml.cs
    11. Reviewing MainPage.xaml
    12. Reviewing MainPage.xaml.cs
    13. Reviewing the project references
    14. Reviewing the project properties
    15. XAML basics
    16. Building the model
    17. Creating sample data
    18. Building the initial UI
    19. Completing the data-binding initialization
    20. Creating the DataTemplate and binding the UI
    21. Understanding WinUI and UWP
    22. Understanding the UWP app model
    23. Working with WinUI controls, properties, and events
    24. Adding a ListView header
    25. Creating the ComboBox filter
    26. Adding a new item button
    27. Summary
    28. Questions
  9. Chapter 3: MVVM for Maintainability and Testability
    1. Technical requirements
    2. Understanding MVVM
    3. MVVM – the big picture
    4. MVVM libraries for WinUI
    5. Windows Community Toolkit MVVM library
    6. Prism Library
    7. MVVMCross
    8. Choosing a framework for WinUI applications
    9. Understanding data binding in WinUI
    10. What are markup extensions?
    11. Binding markup extension
    12. x:Bind markup extension
    13. Updating View data with INotifyPropertyChanged
    14. Updating collection data with INotifyCollectionChanged
    15. Implementing MVVM in WinUI applications
    16. Working with events and commands
    17. Implementing ICommand
    18. Using commands in the ViewModel
    19. Updating the View
    20. Choosing a unit test framework
    21. Summary
    22. Questions
  10. Chapter 4: Advanced MVVM Concepts
    1. Technical requirements
    2. Understanding the basics of DI
    3. Using DI with ViewModel classes
    4. Leveraging x:Bind with events
    5. Page navigation with MVVM and DI
    6. Adding ItemDetailsPage
    7. Adding new interfaces and services
    8. Creating a navigation service
    9. Creating a data service
    10. Increasing maintainability by consuming services
    11. Handling parameters in ItemDetailsPage
    12. Creating the ItemDetailsViewModel class
    13. Summary
    14. Questions
  11. Chapter 5: Exploring WinUI Controls
    1. Technical requirements
    2. Understanding what WinUI offers developers
    3. Animated visual player (Lottie)
    4. Navigation view
    5. Parallax view
    6. Rating control
    7. Two-pane view
    8. Exploring the XAML Controls Gallery Windows app
    9. Learning about the ScrollViewer control
    10. Reviewing what's new in WinUI 3.0
    11. Backward compatibility
    12. Visual Studio tooling
    13. Input validation
    14. A new WebView
    15. Exploring the XamlDirect APIs for middleware authors
    16. Adding some new controls to the project
    17. Using the SplitButton control
    18. Adding a TeachingTip to the save button
    19. Summary
    20. Questions
    21. Further reading
  12. Chapter 6: Leveraging Data and Services
    1. Technical requirements
    2. Managing application state with app life cycle events
    3. Exploring Windows application life cycle events
    4. Life cycle events of WinUI applications
    5. Creating a SQLite data store
    6. What is SQLite?
    7. Adding SQLite to DataService
    8. Leveraging a Micro ORM to simplify data access
    9. Adding Dapper to the project
    10. Updating the data service's initialization
    11. Retrieving data via services
    12. Performing data validation with MVVM
    13. Summary
    14. Questions
  13. Section 2: Extending WinUI and Modernizing Applications
  14. Chapter 7: Fluent Design System for Windows Applications
    1. Technical requirements
    2. What is the Fluent Design System?
    3. Exploring Fluent Design for Windows
    4. Controls
    5. Patterns
    6. Layout
    7. Input
    8. Style
    9. Incorporating Fluent Design in WinUI applications
    10. Updating the title bar
    11. Changing the style of MainPage
    12. Changing the style of ItemDetailsPage
    13. Using the Fluent XAML Theme Editor
    14. Colors
    15. Shapes
    16. Using the UWP Resources Gallery
    17. Design resources and toolkits for Fluent Design
    18. Summary
    19. Questions
  15. Chapter 8: Building WinUI Apps with .NET 5
    1. Technical requirements
    2. Creating a WinUI project with .NET 5
    3. What is WinUI in Desktop?
    4. Creating a new WinUI in Desktop project
    5. Exploring the Desktop project structure
    6. Adding the WebView2 control
    7. Exploring the Packaging project
    8. Visual assets in the Manifest Designer
    9. Referencing .NET 5 Libraries from your project
    10. Sharing the .NET 5 library with a WPF application
    11. Creating a WinUI control library
    12. Summary
    13. Questions
  16. Chapter 9: Enhancing Applications with the Windows Community Toolkit
    1. Technical requirements
    2. Introducing the WCT
    3. Origins of the WCT
    4. Reviewing recent toolkit releases
    5. Exploring the Windows Community Toolkit Sample App
    6. Installing and launching the sample app
    7. Controls
    8. WPF and WinForms controls
    9. Using controls from the toolkit
    10. Creating the WinUI in Desktop project
    11. Referencing the WCT packages
    12. Adding data to the DataGrid
    13. Adding controls to the MainWindow
    14. Exploring the toolkit's helpers, services, and extensions
    15. Helpers
    16. Services
    17. MVVM
    18. Extensions
    19. Summary
    20. Questions
  17. Chapter 10: Modernizing Existing Win32 Applications with XAML Islands
    1. Technical requirements
    2. What is XAML Islands?
    3. Modernizing a WinForms application with XAML Islands
    4. Creating a shared class library project
    5. Creating the WinForms host project
    6. Modernizing a WPF application with XAML Islands
    7. Using the UWP MapControl in WPF
    8. Using the WebViewCompatible browser control in WPF
    9. Working with the WebView2 browser control in WinForms
    10. Summary
    11. Questions
  18. Section 3: Build and Deploy on Windows and Beyond
  19. Chapter 11: Debugging WinUI Applications with Visual Studio
    1. Technical requirements
    2. Debugging in Visual Studio
    3. Debugging local applications
    4. Debugging remote applications
    5. Common XAML layout mistakes
    6. Improving your XAML with static code analysis
    7. Learning to pinpoint data binding errors
    8. Common mistakes in data binding
    9. Using the XAML Binding Failures window
    10. Debugging live data with Live Visual Tree and Live Property Explorer
    11. Coding with XAML Hot Reload
    12. Debugging with Live Visual Tree and Live Property Explorer
    13. Summary
    14. Questions
  20. Chapter 12: Hosting an ASP.NET Core Blazor Application in WinUI
    1. Technical requirements
    2. Getting started with ASP.NET Core and Blazor
    3. Exploring some history of ASP.NET and ASP.NET Core
    4. What is Blazor?
    5. WebAssembly and client-side .NET development
    6. Creating a Blazor Wasm application
    7. Building a simple application for tracking tasks
    8. Exploring Blazor Wasm deployment options
    9. Deployment options for Blazor Wasm projects
    10. Publishing Blazor to Azure Static Web Apps hosting
    11. Pushing the project to GitHub
    12. Creating an Azure Static Web Apps resource
    13. Publishing an application with GitHub Actions
    14. Hosting your Blazor application in the WinUI WebView2
    15. Summary
    16. Questions
  21. Chapter 13: Building, Releasing, and Monitoring Applications with Visual Studio App Center
    1. Technical requirements
    2. Getting started with Visual Studio App Center
    3. Creating an App Center account
    4. Creating your first App Center application
    5. Setting up builds in App Center
    6. Integrating App Center with a GitHub repository
    7. Deploying your application with App Center
    8. Creating early releases of your application or beta testers
    9. Application monitoring and analytics
    10. Instrumenting your code
    11. Gathering and analyzing App Center crash reports
    12. Summary
    13. Questions
  22. Chapter 14: Packaging and Deploying WinUI Applications
    1. Technical requirements
    2. Discovering application packaging and MSIX basics
    3. What is MSIX?
    4. Reviewing MSIX tools and resources
    5. Getting started with application packaging in Visual Studio
    6. Deploying applications with Windows Package Manager
    7. Adding a package to the community repository
    8. Using WinGet for package management
    9. Distributing applications with the Microsoft Store
    10. Preparing a free application for the Microsoft Store
    11. Uploading a package to the Store
    12. Sideloading WinUI applications with MSIX
    13. Creating an MSIX package for sideloading
    14. Sideloading an MSIX package
    15. Summary
    16. Questions
  23. 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. Chapter 13
    14. Chapter 14
    15. Why subscribe?
  24. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Leave a review - let other readers know what you think
18.219.22.169