Skip to content

A WPF message box, with optional features like custom buttons, textbox and checkbox.

License

Notifications You must be signed in to change notification settings

Otiel/WpfMessageBox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Icon WpfMessageBox

Nuget build:master status build:develop status

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 MessageBoxResults.
  • Uses the standard MessageBox icons.
  • Ability to define custom buttons text.
  • Optional header text.
  • Optional TextBox.
  • Optional CheckBox.

Screenshot 1 Screenshot 2

Usage

  1. Install through Nuget

  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.

License

WpfMessageBox is licensed under the MIT license - see the LICENSE file for details.

About

A WPF message box, with optional features like custom buttons, textbox and checkbox.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages