Windows App SDK Samples

repository·main·Indexed 21 days ago

https://github.com/microsoft/windowsappsdk-samples

A collection of functional samples for the Windows App SDK demonstrating features such as AI (Phi Silica, OCR, Windows ML), graphics (Mica, DWriteCore, Composition), app lifecycle, deployment, notifications, XAML Islands, and Windows Widgets. Includes guidance on building and running samples in Visual Studio, handling packaged vs. unpackaged apps, and implementing specific APIs like Dynamic Dependencies and BackgroundTaskBuilder.

Tokens
45.7K
Snippets
107
Records
212
Agent score
76%

What's inside windowsappsdk-samples

  1. Overview of Windows Input and Composition Samples

    main

    The Windows Input and Composition Samples repository provides code examples and demos for building high-performance, engaging user interfaces using the Windows App SDK.

    This project focuses on the platform building blocks of the Fluent Design System, specifically leveraging the following namespaces:

    • Microsoft.UI.Composition: For low-level visual composition and animations.
    • Microsoft.UI.Input: For advanced input handling and interaction.

    These samples are designed for developers working with WinUI 3 who want to move beyond standard XAML controls to create custom, fluid UI experiences.

  2. Overview of the Photo Editor Sample

    main

    The Photo Editor is a sample application designed to demonstrate image viewing and editing capabilities using the Windows App SDK. It showcases how to retrieve photos from the local Pictures library and apply various photo effects.

    Key technical demonstrations include:

    • XAML Layout: Basic, adaptive, and tailored layouts.
    • Data Binding: Using the {x:Bind} markup extension.
    • UI Customization: Styling and connected animations.
    • Image Effects: Utilizing Windows.UI.Composition and the Microsoft.Graphics.Win2D NuGet package for immediate-mode 2D graphics rendering.
    • Performance: Loading images via data virtualization to handle large collections efficiently.
  3. Overview of Windows App SDK sample categories

    main

    This repository provides functional samples across several key domains of the Windows App SDK:

    • Artificial Intelligence: Demonstrates Windows AI APIs (Phi Silica, OCR, Imaging) and Windows ML (running ONNX models on CPU/GPU/NPU).
    • App Lifecycle & System Services: Covers activation kinds, single/multi-instancing, power/system state notifications, app restarts, and Share Target functionality.
    • Deployment: Shows how to use the Deployment Manager, launch installers without console windows, and run unpackaged (non-MSIX) applications.
    • Graphics & UI: Includes Mica material implementation, DWriteCore text rendering, Windowing APIs, and Microsoft.UI.Composition/Input/SceneGraph.
    • Notifications: Showcases both Push and App Notifications.
    • Islands: Demonstrates adding WinAppSDK XAML content into existing Win32 applications.
    • Widgets: Demonstrates authoring Windows Widgets.
    • Runtime Components: Shows how to author Windows Runtime Components in C# with custom WinUI controls.
  4. Use the AppWindow class for window management

    main

    The Windowing gallery samples demonstrate how to use the AppWindow class to manage an application's window. This includes managing window size, position, and title bar customization.

    Title Bar Customization Note

    Customizing a window's TitleBar using the AppWindowTitleBar APIs is only supported on Windows 11 or later. To ensure compatibility, you should check support using the IsCustomizationSupported method.

    // Conceptual check for TitleBar customization support
    if (appWindowTitleBar.IsCustomizationSupported()) 
    {
        // Perform customization
    }
  5. Author and consume C# Windows Runtime Components with WinUI controls

    main

    This sample demonstrates the workflow for creating C# components that contain WinUI controls (such as UserControl and Custom Control) using C#/WinRT, and subsequently consuming those components in both C++ and C# applications.

    Project Structure

    • WinUICsComponent: The core C# Windows Runtime component library. It uses the Microsoft.Windows.CsWinRT NuGet package to generate the component.
    • CppApp: A packaged C++ WinUI application that consumes the component.
    • CppAppUnpackaged: An unpackaged C++ WinUI application that consumes the component.
    • CsApp: A packaged C# WinUI application that consumes the component.
  6. Use Push Notifications in an unpackaged app

    main

    This sample demonstrates how to use the Windows App SDK Push Notifications APIs within an unpackaged application. It covers two primary workflows:

    1. Requesting a WNS Channel URI: The app uses the Windows App SDK to obtain a unique WNS Channel URI. This URI identifies the specific app instance for a current user on a specific device, which an external app server uses to target notifications to that app.
    2. Handling Activations: The app registers for both foreground and background activation to ensure it can respond to incoming notifications regardless of its current state.
  7. Available Windows ML Sample Categories

    main

    The repository provides samples across multiple languages and deployment types:

    C++ Samples

    • CppConsoleDesktop: Basic console app demonstrating EP discovery, command-line options, and model compilation.
    • CppConsoleDesktop.FrameworkDependent: Uses shared runtime for a smaller deployment footprint.
    • CppConsoleDesktop.SelfContained: Standalone deployment with no runtime dependencies.
    • WinMLEpCatalog (CMake): Uses the WinML C API with CMake build system and automatic NuGet restore.
    • cpp-abi: Direct implementation using raw COM interfaces and automatic ABI header generation.

    C# Samples

    • CSharpConsoleDesktop: Basic console application using shared helpers.
    • GUI Applications: Image classification examples implemented in WPF, Windows Forms, and WinUI 3.

    Python Samples

    • SqueezeNetPython: Demonstrates image classification using WinML Python bindings and batch image processing.