AdaptiveCard: Action.ToggleVisibility for Action

huangapple go评论66阅读模式
英文:

AdaptiveCard: Action.ToggleVisibility for Action

问题

以下是您要翻译的内容:

"Is it possible to toggle the visibility of an Adaptivecard action? The following does not work:

{
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "Press the buttons to toggle the button!",
"wrap": true
}
],
"actions": [
{
"id": "btnShow",
"type": "Action.ToggleVisibility",
"title": "Show!",
"targetElements": [
{
"elementId": "btnHide",
"isVisible": true
},
{
"elementId": "btnShow",
"isVisible": false
}
]
},
{
"id": "btnHide",
"type": "Action.ToggleVisibility",
"title": "Hide!",
"targetElements": [
{
"elementId": "btnHide",
"isVisible": false
},
{
"elementId": "btnShow",
"isVisible": true
}
],
"isVisible": false
}
]
}"

英文:

Is it possible to toggle the visibility of an Adaptivecard action? The following does not work:

{
  "type": "AdaptiveCard",
  "version": "1.2",
  "body": [
    {
      "type": "TextBlock",
      "text": "Press the buttons to toggle the button!",
      "wrap": true
    }
  ],
  "actions": [
    {
      "id": "btnShow",
      "type": "Action.ToggleVisibility",
      "title": "Show!",
      "targetElements": [
        {
          "elementId": "btnHide",
          "isVisible": true
        },
        {
          "elementId": "btnShow",
          "isVisible": false
        }
      ]
    },
    {
      "id": "btnHide",
      "type": "Action.ToggleVisibility",
      "title": "Hide!",
      "targetElements": [
        {
          "elementId": "btnHide",
          "isVisible": false
        },
        {
          "elementId": "btnShow",
          "isVisible": true
        }
      ],
      "isVisible": false
    }
  ]
}

答案1

得分: 1

{
  "type": "AdaptiveCard",
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.2",
  "body": [
    {
      "type": "TextBlock",
      "text": "按下按钮以切换按钮状态!",
      "wrap": true
    },
    {
      "id": "btnShow",
      "type": "ActionSet",
      "actions": [
        {
          "type": "Action.ToggleVisibility",
          "title": "显示!",
          "targetElements": [
            {
              "elementId": "btnHide",
              "isVisible": true
            },
            {
              "elementId": "btnShow",
              "isVisible": false
            }
          ]
        }
      ]
    },
    {
      "id": "btnHide",
      "type": "ActionSet",
      "actions": [
        {
          "type": "Action.ToggleVisibility",
          "title": "隐藏!",
          "targetElements": [
            {
              "elementId": "btnHide",
              "isVisible": false
            },
            {
              "elementId": "btnShow",
              "isVisible": true
            }
          ]
        }
      ],
      "isVisible": false
    }
  ],
  "actions": []
}
英文:

Actions alone cannot be hidden/shown. They need to be nested in a container within body, which supports that feature. This one is an alternative:

{
  "type": "AdaptiveCard",
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.2",
  "body": [
    {
      "type": "TextBlock",
      "text": "Press the buttons to toggle the button!",
      "wrap": true
    },

    {
      "id": "btnShow",
      "type": "ActionSet",
      "actions": [
        {
          "type": "Action.ToggleVisibility",
          "title": "Show!",
          "targetElements": [
            {
              "elementId": "btnHide",
              "isVisible": true
            },
            {
              "elementId": "btnShow",
              "isVisible": false
            }
          ]
        }
      ]
    },


    {
      "id": "btnHide",
      "type": "ActionSet",
      "actions": [
        {
          "type": "Action.ToggleVisibility",
          "title": "Hide!",
          "targetElements": [
            {
              "elementId": "btnHide",
              "isVisible": false
            },
            {
              "elementId": "btnShow",
              "isVisible": true
            }
          ]
        }
      ],
      "isVisible": false
    }
  ],

  "actions": []
}

huangapple
  • 本文由 发表于 2023年2月23日 19:18:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/75544102.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定