【问题标题】:Action.ShowCard open by defaultAction.ShowCard 默认打开
【发布时间】:2020-03-30 15:31:06
【问题描述】:

我查看了 git 上有关自适应卡片的各种资源以及查看文档,这并不明显。

我想要一张默认展开而不是关闭以切换为打开的卡片。

由于平台开发支持,我只需要利用 1.0 和 1.1 功能。

【问题讨论】:

  • 我已经设置好我的卡,它目前工作正常,只是它是关闭还是打开。
  • 你觉得我的回答够了吗?如果是这样,请“接受”并投票,以便其他人可以快速找到答案,我可以从我的支持跟踪器中清除它。如果没有,请告诉我我还能提供哪些帮助!

标签: adaptive-cards


【解决方案1】:

您不能在

一旦您能够使用 1.2,您就可以使用 Action.ToggleVisibility。这是一个示例卡片:

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "Container",
            "items": [
                {
                    "type": "TextBlock",
                    "text": "Everything in the blue container will stay when the button is clicked.",
                    "wrap": true
                }
            ],
            "spacing": "ExtraLarge",
            "separator": true,
            "style": "accent"
        },
        {
            "type": "Container",
            "items": [
                {
                    "type": "TextBlock",
                    "text": "Everything in the green container will hide when the button is clicked",
                    "wrap": true
                },
                {
                    "type": "Image",
                    "altText": "",
                    "url": "https://docs.botframework.com/static/devportal/client/images/bot-framework-default.png"
                }
            ],
            "spacing": "None",
            "horizontalAlignment": "Center",
            "style": "good",
            "selectAction": {
                "type": "Action.ToggleVisibility",
                "targetElements": [
                    "hide"
                ]
            },
            "id": "hide"
        },
        {
            "type": "ActionSet",
            "actions": [
                {
                    "type": "Action.ToggleVisibility",
                    "title": "Hide the Green Section",
                    "targetElements": [
                        "hide"
                    ]
                }
            ]
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.0"
}

您可以将该 JSON 粘贴到 Designer 的“Card Payload Editor”中,然后单击“Preview Mode”进行尝试。

请注意,是否支持此功能取决于客户,而不仅仅是卡片架构。


由于您不能使用 1.2,因此可以选择:

  1. 使用提交操作创建卡片
  2. 单击“提交”操作后,让客户端将卡片替换为不包含您要隐藏的部分的卡片。

在 Bot Framework 中,您可以使用 UpdateActivity() 在支持它的频道上完成 #2(一般用户可以在其中编辑消息的任何频道)。

这并不理想,但它是你可以用

【讨论】:

  • 谢谢!这也是我从文档中了解到的。感谢您对有一套好的文档的回应和赞誉。
猜你喜欢
  • 1970-01-01
  • 2020-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-10
  • 2014-01-26
  • 2018-06-24
  • 1970-01-01
相关资源
最近更新 更多