DevKit.Focus.WinUi3.Sharp 0.3.0

dotnet add package DevKit.Focus.WinUi3.Sharp --version 0.3.0
                    
NuGet\Install-Package DevKit.Focus.WinUi3.Sharp -Version 0.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DevKit.Focus.WinUi3.Sharp" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DevKit.Focus.WinUi3.Sharp" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="DevKit.Focus.WinUi3.Sharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DevKit.Focus.WinUi3.Sharp --version 0.3.0
                    
#r "nuget: DevKit.Focus.WinUi3.Sharp, 0.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DevKit.Focus.WinUi3.Sharp@0.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DevKit.Focus.WinUi3.Sharp&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=DevKit.Focus.WinUi3.Sharp&version=0.3.0
                    
Install as a Cake Tool

DevKit.Focus.WinUi3.Sharp

WinUI 3 adapter for DevKit.Focus.Sharp.

It supplies:

  • focus scopes backed by a WinUI visual tree and XamlRoot;
  • a fluent builder for component roots, default targets, owned popups, and availability;
  • explicit DispatcherQueue scheduling;
  • first-activation and reactivation focus restoration.

Simple component

public sealed class TerminalView : FrameworkElement, IKeyboardFocusSurface
{
    public TerminalView()
    {
        IsTabStop = true;
        FocusScope = this.CreateKeyboardFocusScope("terminal");
    }

    public IKeyboardFocusScope FocusScope { get; }
}

Editor scope

FocusScope = WinUi3KeyboardFocusScope
    .For(EditorRoot)
    .Named("editor")
    .Default(EditorControl)
    .Include(FindPopupRoot)
    .AvailableWhen(() => EditorRoot.Visibility == Visibility.Visible)
    .Build();

Each included root is inspected through its own XamlRoot, so owned popup/flyout trees can remain valid members of the logical scope.

Host integration

var coordinator = new KeyboardFocusCoordinator(LogFocus);

using var restoration = window.AttachKeyboardFocusRestoration(
    coordinator,
    () => currentSurface?.FocusScope);

coordinator.PostFocus(
    window.DispatcherQueue,
    terminal.FocusScope,
    new KeyboardFocusRequest(
        KeyboardFocusReason.SurfaceEntered,
        detail: "Panels -> Terminal"));

Requires Windows 10 17763+, .NET 8 or .NET 10, and Windows App SDK 2.4+.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0-windows10.0.19041 is compatible.  net9.0-windows was computed.  net10.0-windows was computed.  net10.0-windows10.0.19041 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0 86 8/27/2026