SuGarToolkit.WPF.Controls.CaptionButtons 1.2.0

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

Native-like Caption Button for WPF

Provides caption buttons in native-like style for WindowChrome.

Features

You can decide for every button:

  • Visibility (Visible, Collapsed, Hidden)
  • IsEnabled (true, false)
  • Height (typically 30 and 48 DIP)

<img width="3313" height="1457" alt="examples" src="https://github.com/user-attachments/assets/d22adf3e-71ae-4831-a4e5-bddab9517c7e" />

Simple example

Just add CaptionButtonBar to your window, every button will change the window state properly. WindowChrome.IsHitTestVisibleInChrome has been set in the ControlTemplate and it will find owner window by Window.GetWindow(this) itself and react to Window.Activated, Window.Deactivated, Window.StateChanged events.

<Window
    xmlns:CaptionButtons="clr-namespace:SuGarToolkit.WPF.Controls.CaptionButtons;assembly=SuGarToolkit.WPF.Controls.CaptionButtons"
    xmlns:system="clr-namespace:System;assembly=netstandard"
    Title="SuGarToolkit.WPF.Controls.CaptionButtons"
    StateChanged="Window_StateChanged"
    ...>

    <WindowChrome.WindowChrome>
        <WindowChrome
            x:Name="WindowChrome"
            CaptionHeight="{Binding CaptionButtonHeight, Mode=OneWay}"
            UseAeroCaptionButtons="False" />
    </WindowChrome.WindowChrome>

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Grid x:Name="TitleBarArea" Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions>

            <CaptionButtons:CaptionButtonBar
                Grid.Column="1"
                Height="30"
                IsMaximizeButtonEnabled="False"
                IsMinimizeButtonEnabled="False" />
        </Grid>

        <StackPanel Grid.Row="1">
            ...
        </StackPanel>
    </Grid>

</Window>

When the window maximized, content near the edge of the window will be out of the range of the screen. To solve this problem, there is a feasible way: change the content margin when Window.StateChanged.

private void Window_StateChanged(object sender, EventArgs e)
{
    switch (WindowState)
    {
        case WindowState.Maximized:
            double top = SystemParameters.ResizeFrameHorizontalBorderHeight + SystemParameters.FixedFrameHorizontalBorderHeight;
            double left = SystemParameters.ResizeFrameVerticalBorderWidth + SystemParameters.FixedFrameVerticalBorderWidth;
            LayoutRoot.Margin = new Thickness
            {
                Left = left,
                Right = left,
                Top = top,
                Bottom = top
            };
            break;
        default:
            LayoutRoot.Margin = new Thickness(0);
            break;
    }
}
Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.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.2.0 206 10/6/2025
1.1.0 189 9/12/2025