优化更新代码,添加界面功能并整合
This commit is contained in:
57
WPFluent/Extensions/ContentDialogServiceExtensions.cs
Normal file
57
WPFluent/Extensions/ContentDialogServiceExtensions.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user