SnapLayout.Trigger 1.0.3

dotnet add package SnapLayout.Trigger --version 1.0.3
                    
NuGet\Install-Package SnapLayout.Trigger -Version 1.0.3
                    
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="SnapLayout.Trigger" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SnapLayout.Trigger" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="SnapLayout.Trigger" />
                    
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 SnapLayout.Trigger --version 1.0.3
                    
#r "nuget: SnapLayout.Trigger, 1.0.3"
                    
#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 SnapLayout.Trigger@1.0.3
                    
#: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=SnapLayout.Trigger&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=SnapLayout.Trigger&version=1.0.3
                    
Install as a Cake Tool

SnapLayout.Trigger

.NET NuGet NuGet Downloads License: MIT

A lightweight WPF library that enables Windows 11 Snap Layout functionality on custom window maximize buttons. Provides native Windows 11-like behavior with both mouse hover and mouse hold interactions.

Features

  • Mouse Hover Activation: Snap Layout popup appears when hovering over the maximize button
  • 🖱️ Mouse Hold Activation: Snap Layout popup appears after holding the mouse button for 400ms
  • 🎯 Single Method Integration: One line of code to enable functionality
  • 🪟 Windows 11 Native Behavior: Mimics the native Windows 11 Snap Layout experience
  • 🎨 Custom Window Chrome Support: Perfect for applications with custom title bars
  • Lightweight: Minimal dependencies and performance overhead
  • 🖥️ Multi-Monitor Support: Works seamlessly across multiple displays

Requirements

  • .NET 10.0-windows or later
  • WPF Application
  • Windows 11 (Snap Layouts are a Windows 11 feature)

Installation

NuGet Package Manager

Install-Package SnapLayout.Trigger

.NET CLI

dotnet add package SnapLayout.Trigger

Package Reference

<PackageReference Include="SnapLayout.Trigger" Version="1.0.0" />

Quick Start

Basic Usage

using System.Windows;
using SnapLayout.Trigger;

public partial class MainWindow : Window
{ 
    public MainWindow() {
        InitializeComponent();

        // Enable Snap Layout on your custom maximize button
        SnapLayoutTrigger.Initialize(MaximizeButton);
    }
}

That's it! Just one line of code. 🎉

How It Works

The library uses P/Invoke to simulate the Win+Z keyboard shortcut that triggers Windows 11's native Snap Layout functionality:

  1. Mouse Hover: When the mouse enters the maximize button, the Snap Layout popup appears immediately
  2. Mouse Hold: When the left mouse button is pressed and held for 400ms, the Snap Layout popup appears
  3. Quick Click: Normal maximize/restore behavior is preserved

API Reference

public static class SnapLayoutTrigger
{

    /// <summary>
    /// Initializes snap layout behavior by attaching MouseEnter and MouseDown handlers to the maximize button.
    /// </summary> /// <param name="maximizeButton">The maximize button that triggers the Windows snap layout popup.</param>
    /// <exception cref="ArgumentNullException">Thrown when <paramref name="maximizeButton"/> is null.</exception>
    public static void Initialize(Button maximizeButton);
}

Example Project

Run the example project:

cd SnapLayout.Trigger.Example
dotnet run

Testing

Run the NUnit tests:

dotnet test

Known Limitations

  • Windows 11 Only: Snap Layouts are a Windows 11 feature
  • P/Invoke Dependency: Uses Win32 APIs which may be restricted in sandboxed environments
  • Keyboard Simulation: Simulates Win+Z keypress

Documentation

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Stanley Omoregie
Omotech Digital Solutions

Support

Roadmap

  • Support for customizable hold duration
  • Configuration options for hover/hold behavior
  • Additional snap layout customization
  • .NET 9.0 and .NET 8.0 support

Made with ❤️ by Stanley Omoregie
Copyright © 2025 Omotech Digital Solutions

Product Compatible and additional computed target framework versions.
.NET net10.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0-windows7.0

    • No dependencies.

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
1.0.3 83 3/4/2026
1.0.2 79 3/4/2026
1.0.1 74 3/4/2026