58 lines
2.0 KiB
C#
58 lines
2.0 KiB
C#
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
using WPFluent.Controls;
|
|||
|
|
|
|||
|
|
using System.Windows.Controls;
|
|||
|
|
|
|||
|
|
namespace WPFluent.Extensions;
|
|||
|
|
|
|||
|
|
public static class ContentDialogServiceExtensions
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Shows the simple alert-like dialog.
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns>Result of the life cycle of the <see cref="ContentDialog"/>.</returns>
|
|||
|
|
public static Task<ContentDialogResult> ShowAlertAsync(
|
|||
|
|
this IContentDialogService 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);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Shows simple dialog
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dialogService">The <see cref="IContentDialogService"/>.</param>
|
|||
|
|
/// <param name="options">Set of parameters of the basic dialog box.</param>
|
|||
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|||
|
|
/// <returns>Result of the life cycle of the <see cref="ContentDialog"/>.</returns>
|
|||
|
|
public static Task<ContentDialogResult> ShowSimpleDialogAsync(
|
|||
|
|
this IContentDialogService dialogService,
|
|||
|
|
SimpleContentDialogCreateOptions 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);
|
|||
|
|
}
|
|||
|
|
}
|