Class ContentDialogService
Represents a contract with the service that creates ContentDialog.
public class ContentDialogService : IContentDialogService
- Inheritance
-
ContentDialogService
- Implements
- Inherited Members
- Extension Methods
Examples
<ContentPresenter x:Name="RootContentDialogPresenter" Grid.Row="0" />
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"
}
);
Methods
GetContentPresenter()
[Obsolete("Use GetDialogHost instead.")]
public ContentPresenter? GetContentPresenter()
Returns
GetDialogHost()
Provides direct access to the ContentPresenter
public ContentPresenter? GetDialogHost()
Returns
- ContentPresenter
Reference to the currently selected ContentPresenter which displays the ContentDialog's.
SetContentPresenter(ContentPresenter)
[Obsolete("Use SetDialogHost instead.")]
public void SetContentPresenter(ContentPresenter contentPresenter)
Parameters
contentPresenter
ContentPresenter
SetDialogHost(ContentPresenter)
Sets the ContentPresenter
public void SetDialogHost(ContentPresenter contentPresenter)
Parameters
contentPresenter
ContentPresenter
ShowAsync(ContentDialog, CancellationToken)
Asynchronously shows the specified dialog.
public Task<ContentDialogResult> ShowAsync(ContentDialog dialog, CancellationToken cancellationToken)
Parameters
dialog
ContentDialogThe dialog to be displayed.
cancellationToken
CancellationTokenA cancellation token that can be used to cancel the operation.
Returns
- Task<ContentDialogResult>
A task that represents the asynchronous operation. The task result contains the dialog result.