文档显示了以下C#代码片段:
async void DisplayDeleteFileDialog(){
ContentDialog deleteFileDialog = new ContentDialog{
Title = "Delete file permanently?",
Content = "If you delete this file, you won't be able to recover it. Do you want to delete it?",
PrimaryButtonText = "Delete",
CloseButtonText = "Cancel"
};
ContentDialogResult result = await deleteFileDialog.ShowAsync();
// Delete the file if the user clicked the primary button.
/// Otherwise, do nothing.
if (result == ContentDialogResult.Primary) {
// Delete the file.
}
else {
// The user clicked the CLoseButton, pressed ESC, Gamepad B, or the system back button.
// Do nothing.
}
}
我请求的是此代码片段的C++/winRT版本。
发布于 2019-01-17 01:39:05
IAsyncAction Async()
{
ContentDialog dialog;
dialog.Title(box_value(L"title"));
dialog.Content(box_value(L"content"));
dialog.PrimaryButtonText(L"primary");
dialog.CloseButtonText(L"close");
auto result = co_await dialog.ShowAsync();
if (result == ContentDialogResult::Primary)
{
}
}
发布于 2020-09-02 18:26:37
我想在单击按钮时打开内容对话框,所以我尝试了Kenny Kerr提供的代码片段。一切似乎工作正常,没有错误,但当我点击按钮时,没有看到任何对话框。我在下面的代码中修复了这个问题
dialog.XamlRoot(myButton().XamlRoot());
在auto result = co_await dialog.ShowAsync()
行之前。
https://stackoverflow.com/questions/54209679
复制相似问题