using System.Windows.Controls;
using WPFluent.Controls;
namespace WPFluent.Extensions;
public static class ContentDialogServiceExtensions
{
///
/// Shows the simple alert-like dialog.
///
/// Result of the life cycle of the .
public static Task ShowAlertAsync(
this ContentDialogService dialogService,
string title,
string message,
string closeButtonText,
CancellationToken cancellationToken = default)
{
var dialog = new ContentDialog();
dialog.SetCurrentValue(ContentDialog.TitleProperty, title);
dialog.SetCurrentValue(ContentControl.ContentProperty, message);
dialog.SetCurrentValue(ContentDialog.CloseButtonTextProperty, closeButtonText);
return dialogService.ShowAsync(dialog, cancellationToken);
}
///
/// Shows simple dialog
///
/// The .
/// Set of parameters of the basic dialog box.
/// The cancellation token.
/// Result of the life cycle of the .
public static Task ShowSimpleDialogAsync(
this ContentDialogService dialogService,
SimpleContentDialogOptions options,
CancellationToken cancellationToken = default)
{
var dialog = new ContentDialog()
{
Title = options.Title,
Content = options.Content,
CloseButtonText = options.CloseButtonText,
PrimaryButtonText = options.PrimaryButtonText,
SecondaryButtonText = options.SecondaryButtonText,
VerticalContentAlignment = VerticalAlignment.Center,
HorizontalContentAlignment = HorizontalAlignment.Center
};
return dialogService.ShowAsync(dialog, cancellationToken);
}
}