https://github.com/otiel/wpfmessagebox
A WPF message box, with optional features like custom buttons, textbox and checkbox.
https://github.com/otiel/wpfmessagebox
c-sharp message-box windows wpf
Last synced: 3 months ago
JSON representation
A WPF message box, with optional features like custom buttons, textbox and checkbox.
- Host: GitHub
- URL: https://github.com/otiel/wpfmessagebox
- Owner: Otiel
- License: mit
- Created: 2019-06-10T07:59:34.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-14T16:38:37.000Z (almost 6 years ago)
- Last Synced: 2025-02-28T20:35:50.746Z (3 months ago)
- Topics: c-sharp, message-box, windows, wpf
- Language: C#
- Size: 75.2 KB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
WpfMessageBox
[](https://www.nuget.org/packages/WpfMessageBox) [](https://ci.appveyor.com/project/Otiel/wpfmessagebox/branch/master) [](https://ci.appveyor.com/project/Otiel/wpfmessagebox/branch/develop)
## Description
WpfMessageBox is a WPF message box implementation, aimed to be visually balanced between the default WPF style and the native .NET MessageBox. It offers the following features:
* Returns the standard .NET [MessageBoxResult](https://docs.microsoft.com/en-us/dotnet/api/system.windows.messageboxresult)s.
* Uses the standard MessageBox [icons](https://docs.microsoft.com/en-us/windows/desktop/uxguide/vis-std-icons).
* Ability to define custom buttons text.
* Optional header text.
* Optional TextBox.
* Optional CheckBox.
## Usage
1. Install through [Nuget](https://www.nuget.org/packages/WpfMessageBox)
2. WpfMessageBox uses static method like the standard .NET MessageBox:```
using WpfMessageBoxLibrary;MessageBoxResult result = WpfMessageBox.Show("Some text", "Some title", MessageBoxButton.OK, MessageBoxImage.Exclamation);
```
3. In order to use the extra features offered by WpfMessageBox, you need to initialize a new `WpfMessageBoxProperties` which will hold the desired properties, then use the relevant static method:```
using WpfMessageBoxLibrary;var msgProperties = new WpfMessageBoxProperties() {
Button = MessageBoxButton.OKCancel,
ButtonOkText = "Set name",
CheckBoxText = "Don't ask again",
Image = MessageBoxImage.Exclamation,
Header = "No name defined",
IsCheckBoxChecked = true,
IsCheckBoxVisible = true,
IsTextBoxVisible = true,
Text = "Please enter the name to use. You can leave the field empty in order to continue using the default name.",
Title = "A nice example",
};MessageBoxResult result = WpfMessageBox.Show(this, ref msgProperties);
```4. The `WpfMessageBoxProperties` object allows you to retrieve the `TextBox` and `CheckBox` values after the user closed the message box:
```
bool checkBoxChecked = msgProperties.IsCheckBoxChecked;
string textBoxContent = msgProperties.TextBoxText;
```More examples can be found in the Demo project of this repository.
## Release notes
See the [changelog](CHANGELOG.md).
## License
WpfMessageBox is licensed under the MIT license - see the [LICENSE](LICENSE) file for details.