Interface IContentDialogService
Represents a contract with the service that creates ContentDialog.
public interface IContentDialogService
- Extension Methods
Examples
<ContentDialogHost 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.")]
ContentPresenter? GetContentPresenter()
Returns
GetDialogHost()
Provides direct access to the ContentPresenter
[Obsolete("Use GetDialogHostEx() instead to access enhanced modal features.", false)]
ContentPresenter? GetDialogHost()
Returns
- ContentPresenter
Reference to the currently selected ContentPresenter which displays the ContentDialog's.
Remarks
DEPRECATED: This method is obsolete. Use GetDialogHostEx() instead.
GetDialogHostEx()
Gets the ContentDialogHost currently associated with the content.
ContentDialogHost? GetDialogHostEx()
Returns
- ContentDialogHost
The associated ContentDialogHost instance, or null if no dialog host is currently assigned.
SetContentPresenter(ContentPresenter)
[Obsolete("Use SetDialogHost instead.")]
void SetContentPresenter(ContentPresenter contentPresenter)
Parameters
contentPresenterContentPresenter
SetDialogHost(ContentPresenter)
Sets the ContentPresenter
[Obsolete("SetDialogHost(ContentPresenter) is deprecated. Use SetDialogHost(ContentDialogHost) instead for better modal features.")]
void SetDialogHost(ContentPresenter dialogHost)
Parameters
dialogHostContentPresenterContentPresenter inside of which the dialogue will be placed. The new ContentDialog will replace the current Content.
Remarks
DEPRECATED: This method is obsolete. Use SetDialogHost(ContentDialogHost) instead.
SetDialogHost(ContentDialogHost)
Sets the ContentDialogHost that will host and present content dialogs.
void SetDialogHost(ContentDialogHost dialogHost)
Parameters
dialogHostContentDialogHostThe ContentDialogHost instance to use for dialog presentation.
ShowAsync(ContentDialog, CancellationToken)
Asynchronously shows the specified dialog.
Task<ContentDialogResult> ShowAsync(ContentDialog dialog, CancellationToken cancellationToken)
Parameters
dialogContentDialogThe dialog to be displayed.
cancellationTokenCancellationTokenA 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.