SuGarToolkit.WPF.Controls.Dialogs 1.0.0

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

WindowedContentDialog for WPF

Show ContentDialog similar to WinUI3 and MessageBox in WinUI3 style in a separate window.

There has been WindowedContentDialog for WinUI3: https://github.com/SuGar0218/WindowedContentDialog

This library depends on the new Fluent style provided for WPF in .NET 9.

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Themes/Fluent.xaml" />
</ResourceDictionary.MergedDictionaries>

Attention namespace

Some class names are the same as them in namespace System.Windows, such as MessageBox and MessageBoxResult.

If you want to use Fluent style MessageBox instead of traditional MessageBox:

using MessageBox = SuGarToolkit.WPF.Controls.Dialogs.MessageBox;
using MessageBoxOptions = SuGarToolkit.WPF.Controls.Dialogs.MessageBoxOptions;
using MessageBoxResult = SuGarToolkit.WPF.Controls.Dialogs.MessageBoxResult;

Using in { code-behind }

Using similarly to ContentDialog in WinUI 3

using SuGarToolkit.WPF.Controls.Dialogs;

WindowedContentDialog dialog = new()
{
    WindowTitle = "Title of the dialog window",
    Title = "Title displayed in the dialog header",
    Content = "The content can be text or UIElement.",

    PrimaryButtonText = "PrimaryButtonText",
    SecondaryButtonText = "SecondaryButtonText",
    CloseButtonText = "CloseButtonText",
    DefaultButton = ContentDialogButton.Primary,

    IsModal = true,
    OwnerWindow = Application.Current.MainWindow,
    CenterInParent = viewModel.ContentDialogSettings.CenterInParent
};
ContentDialogResult result = dialog.Show();

If you want to prevent dialog from closing after buttons clicked, please handle click event and set e.Cancel = true where e is CancelEventArgs.

dialog.PrimaryButtonClick += (o, e) => e.Cancel = true;

Using similarly to MessageBox in WPF or WinForm

using SuGarToolkit.WPF.Controls.Dialogs;
using MessageBox = SuGarToolkit.WPF.Controls.Dialogs.MessageBox;
using MessageBoxOptions = SuGarToolkit.WPF.Controls.Dialogs.MessageBoxOptions;
using MessageBoxResult = SuGarToolkit.WPF.Controls.Dialogs.MessageBoxResult;

MessageBoxResult result = MessageBox.Show(
    true,  // whether the MessageBox is modal
    Application.Current.MainWindow,  // owner/parent window of MessageBox
    "The content can be text or UIElement",  // content displayed in MessageBox body
    "The title of MessageBox",  // title displayed in MessageBox header
    MessageBoxButtons.YesNo,  // the button group of MessageBox similar to WinForm
    MessageBoxIcon.Information,  // the icon displayed in MessageBox header
    MessageBoxDefaultButton.Button1,  // which button is default
    new MessageBoxOptions
    {
        CenterInParent = true  // whether to appear at the center of owner/parent window
    }
);

Using in < XAML />

xmlns:dialogs="clr-namespace:SuGarToolkit.WPF.Controls.Dialogs;assembly=SuGarToolkit.WPF.Controls.Dialogs"

Using WindowedContentDialog in <Page.Resources>

<Page.Resources>
    <dialogs:WindowedContentDialog
        x:Key="XamlWindowedContentDialog"
        Title="{Binding ContentDialogSettings.Title, Mode=OneWay}"
        CloseButtonText="{Binding ContentDialogSettings.CloseButtonText, Mode=OneWay}"
        DataContext="{x:Reference ViewModel}"
        DefaultButton="{Binding ContentDialogSettings.DefaultButton, Mode=OneWay}"
        IsModal="{Binding ContentDialogSettings.IsModal, Mode=OneWay}"
        IsPrimaryButtonEnabled="{Binding ContentDialogSettings.IsPrimaryButtonEnabled, Mode=OneWay}"
        IsSecondaryButtonEnabled="{Binding ContentDialogSettings.IsSecondaryButtonEnabled, Mode=OneWay}"
        OwnerWindow="{x:Static app:MainWindow.Current}"
        PrimaryButtonText="{Binding ContentDialogSettings.PrimaryButtonText, Mode=OneWay}"
        SecondaryButtonText="{Binding ContentDialogSettings.SecondaryButtonText, Mode=OneWay}">

        <dialogs:WindowedContentDialog.TitleTemplate>
            <DataTemplate DataType="{x:Type system:String}">
                <dialogs:MessageBoxHeader Icon="Information" Text="{Binding}" />
            </DataTemplate>
        </dialogs:WindowedContentDialog.TitleTemplate>

        <StackPanel>
            <CheckBox Content="Lorem" IsThreeState="True" />
            <CheckBox Content="Ipsum" IsThreeState="True" />
            <CheckBox Content="Dolor" IsThreeState="True" />
            <CheckBox Content="Sit" IsThreeState="True" />
            <CheckBox Content="Amet" IsThreeState="True" />
        </StackPanel>
    </dialogs:WindowedContentDialog>
</Page.Resources>

Using ContentDialogWindow in XAML

<dialogs:ContentDialogWindow
    xmlns:dialogs="clr-namespace:SuGarToolkit.WPF.Controls.Dialogs;assembly=SuGarToolkit.WPF.Controls.Dialogs"
    Title="Sample ContentDialogWindow"
    CloseButtonText="Close"
    DefaultButton="Primary"
    DialogTitle="Sample ContentDialogWindow"
    PrimaryButtonText="Primary Button"
    SecondaryButtonText="Secondary Button"
    ...>

    <StackPanel>
        <CheckBox Content="Using" IsThreeState="True" />
        <CheckBox Content="ContentDialogWindow" IsChecked="True" />
        <CheckBox Content="in XAML" IsThreeState="True" />
    </StackPanel>

</dialogs:ContentDialogWindow>

Product Compatible and additional computed target framework versions.
.NET net9.0-windows7.0 is compatible.  net10.0-windows was computed. 
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
1.0.0 225 9/1/2025
0.0.2-alpha 343 8/25/2025