Skip to content

💬 beautiful, simply, alternative to MessageBox class.

Notifications You must be signed in to change notification settings

FactorySI/SweetAlertSharp

 
 

Repository files navigation

logo

beautiful, simply, alternative for MessageBox class. inspired by sweetalert2

Preview

preview

Installation

PM> Install-Package SweetAlertSharp

Usage

Basic

const result = SweetAlert.Show("Caption", "Content");

Yes No

const result = SweetAlert.Show("Caption", "Content", SweetAlertButton.YesNo);

Yes No Cancel

 const resul = SweetAlert.Show("Caption", "Content", new []{"YES","NO", "CANCEL"}, SweetAlertButton.YesNoCancel, SweetAlertImage.QUESTION);

With Icon

const result = SweetAlert.Show("Caption", "Content", msgImage: SweetAlertImage.INFORMATION);

Custom Button Text

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

var alert = new SweetAlert();
alert.Caption = "Custom Layout";
alert.Message = "Content";
alert.ButtonContent = new StackPanel();

SweetAlertResult result = alert.ShowDialog();

Delay (ex: loading)

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();

About

💬 beautiful, simply, alternative to MessageBox class.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%