https://github.com/jungwoo-an/sweetalertsharp
:speech_balloon: beautiful, simply, alternative to MessageBox class.
https://github.com/jungwoo-an/sweetalertsharp
alert csharp dialog messagebox sweetalert
Last synced: about 1 year ago
JSON representation
:speech_balloon: beautiful, simply, alternative to MessageBox class.
- Host: GitHub
- URL: https://github.com/jungwoo-an/sweetalertsharp
- Owner: Jungwoo-An
- Created: 2019-01-07T14:15:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-01T14:15:45.000Z (almost 7 years ago)
- Last Synced: 2025-04-08T02:43:02.206Z (about 1 year ago)
- Topics: alert, csharp, dialog, messagebox, sweetalert
- Language: C#
- Homepage:
- Size: 146 KB
- Stars: 14
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

beautiful, simply, alternative for MessageBox class.
inspired by [sweetalert2](https://github.com/sweetalert2/sweetalert2)
## Preview

## Installation
```bash
PM> Install-Package SweetAlertSharp
```
## Usage
**Basic**
```cs
const result = SweetAlert.Show("Caption", "Content");
```
**Yes No**
```cs
const result = SweetAlert.Show("Caption", "Content", SweetAlertButton.YesNo);
```
**With Icon**
```cs
const result = SweetAlert.Show("Caption", "Content", msgImage: SweetAlertImage.INFORMATION);
```
**Custom Button Text**
```cs
var alert = new SweetAlert();
alert.Caption = "Custom Alert";
alert.Message = "Content";
alert.MsgButton = SweetAlertButton.YesNo;
alert.OkText = "Yes.";
alert.CancelText = "No!";
SweetAlertResult result = alert.ShowDialog();
```
**Custom Button Layout**
```cs
var alert = new SweetAlert();
alert.Caption = "Custom Layout";
alert.Message = "Content";
alert.ButtonContent = new StackPanel();
SweetAlertResult result = alert.ShowDialog();
```
**Delay (ex: loading)**
```cs
var canClose = false;
var alert = new SweetAlert();
alert.Caption = "Delay";
alert.Message = "Wait!";
alert.ButtonContent = "Loading ...";
alert.PreClose += (object window, CancelEventArgs cancelEvent) =>
{
cancelEvent.Cancel = !canClose;
};
Task.Run(async () =>
{
await Task.Delay(3000);
await Dispatcher.BeginInvoke(new Action(() =>
{
canClose = true;
alert.ButtonContent = "Ok!";
}));
});
var reuslt = alert.ShowDialog();
```