Chapter.Net.WPF.MessageBoxes
1.0.0
See the version list below for details.
dotnet add package Chapter.Net.WPF.MessageBoxes --version 1.0.0
NuGet\Install-Package Chapter.Net.WPF.MessageBoxes -Version 1.0.0
<PackageReference Include="Chapter.Net.WPF.MessageBoxes" Version="1.0.0" />
paket add Chapter.Net.WPF.MessageBoxes --version 1.0.0
#r "nuget: Chapter.Net.WPF.MessageBoxes, 1.0.0"
// Install Chapter.Net.WPF.MessageBoxes as a Cake Addin #addin nuget:?package=Chapter.Net.WPF.MessageBoxes&version=1.0.0 // Install Chapter.Net.WPF.MessageBoxes as a Cake Tool #tool nuget:?package=Chapter.Net.WPF.MessageBoxes&version=1.0.0
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
- Example 2
- Example 3
- Example 4
- Example 5
- Example 6
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
Installation:
- Install the Chapter.Net.WPF.MessageBoxes library via NuGet Package Manager:
dotnet add package Chapter.Net.WPF.MessageBoxes
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) { }
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);
Localization:
- Translate yes and no buttons
var options = new MessageBoxOptions(); options.Strings.Yes = "Yay"; options.Strings.No = "Nay"; MessageBox.Show(this, "Message", "Caption", options);
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);
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(); } }
Links
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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net7.0-windows7.0 is compatible. net8.0-windows was computed. net8.0-windows7.0 is compatible. |
-
net6.0-windows7.0
- Chapter.Net.WPF (>= 1.0.0)
- Chapter.Net.WPF.Behaviors (>= 1.0.0)
-
net7.0-windows7.0
- Chapter.Net.WPF (>= 1.0.0)
- Chapter.Net.WPF.Behaviors (>= 1.0.0)
-
net8.0-windows7.0
- Chapter.Net.WPF (>= 1.0.0)
- Chapter.Net.WPF.Behaviors (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.