首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >C++/winRT xaml ContentDialog示例

C++/winRT xaml ContentDialog示例
EN

Stack Overflow用户
提问于 2019-01-16 10:38:47
回答 2查看 511关注 0票数 1

文档显示了以下C#代码片段:

代码语言:javascript
运行
复制
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版本。

EN

回答 2

Stack Overflow用户

发布于 2019-01-17 01:39:05

代码语言:javascript
运行
复制
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)
    {

    }
}
票数 3
EN

Stack Overflow用户

发布于 2020-09-02 18:26:37

我想在单击按钮时打开内容对话框,所以我尝试了Kenny Kerr提供的代码片段。一切似乎工作正常,没有错误,但当我点击按钮时,没有看到任何对话框。我在下面的代码中修复了这个问题

代码语言:javascript
运行
复制
 dialog.XamlRoot(myButton().XamlRoot());

auto result = co_await dialog.ShowAsync()行之前。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54209679

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档