A tutorial on using ContentDialog #726
-
Regarding the tutorial on using ContentDialog, I have searched many websites on Google, but there is no tutorial on using ContentDialog for WPF UI. When I tried writing multiple times, every time I executed it, it caused the application to crash. I only found the API on the official website without any examples, and so far, there is still no pop-up window displayed |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Im also new to this but there has been some changes. By looking in the Gallery i think i understood a little of how it works. To show dialogs you have to create and use the service XAML CODE And as the examples from the gallery, you can show the dialogs like this: Basic alerts: var result = await _contentDialogService.ShowAlertAsync("Title", "Message", "Close", cancellationToken);
var result = await _contentDialogService.ShowSimpleDialogAsync(
new SimpleContentDialogCreateOptions()
{
Title = "Save your work?",
Content = content,
PrimaryButtonText = "Save",
SecondaryButtonText = "Don't Save",
CloseButtonText = "Cancel",
}
);````
//or you can extend the ContentDialog class and create your own content dialog like (kinda genius ngl):
var termsOfUseContentDialog = new TermsOfUseContentDialog(
_contentDialogService.GetContentPresenter()
);
await termsOfUseContentDialog.ShowAsync(); |
Beta Was this translation helpful? Give feedback.
Im also new to this but there has been some changes. By looking in the Gallery i think i understood a little of how it works.
To show dialogs you have to create and use the service
IContentDialogService
and set its contentPresenterXAML
<ContentPresenter x:Name="RootContentDialog" Grid.Row="0" />
CODE
contentDialogService.SetContentPresenter(RootContentDialog);
And as the examples from the gallery, you can show the dialogs like this:
Basic alerts: