Files
Shrlalgo.RvKits/WPFluent/Services/IContentDialogService.cs
2025-04-24 20:56:44 +08:00

43 lines
1.9 KiB
C#

using System.Windows.Controls;
using WPFluent.Controls;
namespace WPFluent;
/// <summary>
/// Represents a contract with the service that creates <see cref="ContentDialog"/>.
/// </summary>
/// <example>
/// <code lang="xml">&lt;ContentPresenter x:Name="RootContentDialogPresenter" Grid.Row="0" /&gt;</code> <code
/// lang="csharp">IContentDialogService contentDialogService = new ContentDialogService();
/// contentDialogService.SetContentPresenter(RootContentDialogPresenter); await _contentDialogService.ShowAsync( new
/// ContentDialog(){ Title = "The cake?", Content = "IS A LIE!", PrimaryButtonText = "Save", SecondaryButtonText =
/// "Don't Save", CloseButtonText = "Cancel" } );</code>
/// </example>
public interface IContentDialogService
{
/// <summary>
/// Provides direct access to the <see cref="ContentPresenter"/>
/// </summary>
/// <returns>Reference to the currently selected <see cref="ContentPresenter"/> which displays the <see cref="ContentDialog"/>'s.</returns>
ContentPresenter? GetDialogHost();
/// <summary>
/// Sets the <see cref="ContentPresenter"/>
/// </summary>
/// <param name="dialogHost">
/// <see cref="ContentPresenter"/> inside of which the dialogue will be placed. The new <see cref="ContentDialog"/> will
/// replace the current <see cref="ContentPresenter.Content"/>.
/// </param>
void SetDialogHost(ContentPresenter dialogHost);
/// <summary>
/// Asynchronously shows the specified dialog.
/// </summary>
/// <param name="dialog">The dialog to be displayed.</param>
/// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the dialog result.</returns>
Task<ContentDialogResult> ShowAsync(ContentDialog dialog, CancellationToken cancellationToken);
}