Chapter.Net.WPF.MessageBoxes 2.0.0

dotnet add package Chapter.Net.WPF.MessageBoxes --version 2.0.0                
NuGet\Install-Package Chapter.Net.WPF.MessageBoxes -Version 2.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="Chapter.Net.WPF.MessageBoxes" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Chapter.Net.WPF.MessageBoxes --version 2.0.0                
#r "nuget: Chapter.Net.WPF.MessageBoxes, 2.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.
// Install Chapter.Net.WPF.MessageBoxes as a Cake Addin
#addin nuget:?package=Chapter.Net.WPF.MessageBoxes&version=2.0.0

// Install Chapter.Net.WPF.MessageBoxes as a Cake Tool
#tool nuget:?package=Chapter.Net.WPF.MessageBoxes&version=2.0.0                

<img src="https://raw.githubusercontent.com/dwndlnd/Chapter.Net.WPF.MessageBoxes/master/Icon.png" alt="logo" width="64"/>

Chapter.Net.WPF.MessageBoxes Library

Overview

The System.Windows.MessageBox to use within WPF has two big problems. First is that it looks like windows Classic and it lacks a lot of features. Here the Chapter.Net.WPF.MessageBoxes library steps in. Thats a custom message box made out of a WPF window. It has a lot of additonal features, see below, and it brings build in styles and allows custom styling.

Preview

(Some button labels are n German because the screenshots are made on a German windows)

  • Example 1
    Light Dark Unstyled
  • Example 2
    Light Dark Unstyled
  • Example 3
    Light Dark Unstyled
  • Example 4
    Light Dark Unstyled
  • Example 5
    Light Dark Unstyled
  • Example 6
    Light Dark Unstyled

Features

  • Styling: Build in Light and Dark style and allow passing custom styles.
  • Window Settings: Settings like show in task bar, minimum and maximum sizes, resize modes and more.
  • Additional Buttons: Buttons like Yes To All, Try Again and some more.
  • Do not show again checkbox: Checkbox shown on the bottom left for configure a do not show again.
  • Details: Allow expanding and collapsing an area to display details.
  • Clipboard: Like the original, pressing CTRL+C copies all shown in the message box to the clipboard. That contains the optional details section.
  • Localization: All buttons shown can be localized manually. Those who are available by windows are also auto translated if needed.

Getting Started

  1. Installation:

    • Install the Chapter.Net.WPF.MessageBoxes library via NuGet Package Manager:
    dotnet add package Chapter.Net.WPF.MessageBoxes
    
  2. Usage:

    • Simply use the Chapter.WPF.MessageBox like you would use the build in.
    var result = MessageBox.Show(ownerWindow, "Message", "Caption", MessageBoxButtons.YesNo);
    if (result == MessageBoxResult.Yes)
    {
    }
    
  3. Styling:

    • With build in dark style
    var options = new MessageBoxOptions();
    options.WindowOptions.Theme = WindowTheme.Dark; // The window title bar
    options.Styles.Theme = WindowTheme.Dark; // The controls
    
    MessageBox.Show(this, "Message", "Caption", options);
    
    • With custom styles
    var options = new MessageBoxOptions();
    options.WindowOptions.Theme = WindowTheme.Dark; // The window title bar
    options.Styles.ButtonStyle = myButtonStyle;
    
    MessageBox.Show(this, "Message", "Caption", options);
    
  4. Localization:

    • Translate yes and no buttons
    var options = new MessageBoxOptions();
    options.Strings.Yes = "Yay";
    options.Strings.No = "Nay";
    
    MessageBox.Show(this, "Message", "Caption", options);
    
  5. Details:

    • Show call stack in details pane
    var options = new MessageBoxOptions();
    options.ShowDetails = true;
    options.DetailsText = Environment.StackTrace;
    
    MessageBox.Show(this, "See Details", "Error", options);
    
  6. Do not show again:

    • Add the checkbox and save it accordingly
    var options = new MessageBoxOptions();
    options.ShowDoNotShowAgainCheckBox = true;
    
    var result = MessageBox.Show(this, "You want to close the application?", "Close", options);
    system.DoNotShowAgain = options.IsDoNotShowAgainChecked;
    

Example

  • Save single or all

    public class MainViewModel
    {
        public void SaveAll()
        {
            var options = new MessageBoxOptions();
            options.ShowYesToAllButton = true;
            var result = MessageBox.Show(this, "Save changed files?", "Save", MessageBoxButtons.YesNo, options);
            switch (result)
            {
                case MessageBoxResult.Yes:
                    SaveCurrentFile();
                    break;
                case MessageBoxResult.YesToAll:
                    SaveAllFiles();
                    break;
                case MessageBoxResult.No:
                    break;
            }
        }
    }
    
  • Do not show again

    public class MainViewModel
    {
        public void TryShutdown()
        {
            if (!Settings.DoNotShowAgain)
            {
                var options = new MessageBoxOptions();
                options.ShowDoNotShowAgainCheckBox = true;
    
                var result = MessageBox.Show(this, "You want to close the application?", "Close", options);
                Settings.DoNotShowAgain = options.IsDoNotShowAgainChecked;
                if (result == MessageBoxResult.Yes)
                    Shutdown();
            }
            else
                Shutdown();
        }
    }
    

License

Copyright (c) David Wendland. All rights reserved. Licensed under the MIT License. See LICENSE file in the project root for full license information.

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 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
2.0.0 78 6/7/2024
1.1.0 159 3/31/2024
1.0.0 598 12/24/2023