2017-09-12 43 views
4

如何为容器添加操作? 根据documentation容器类型有一个“操作”对象,但是在adaptive cards visualizer或bot-framework仿真器中测试卡时,不显示按钮。 附上我试图生成的那种卡片的示例。BotFramework自适应卡片 - 容器操作未呈现

感谢您的帮助。

{ 
    "type": "AdaptiveCard", 
    "body": [ 
    { 

     "style":"normal", 
     "type": "Container", 
     "separation" : "strong", 
     "actions": [ 
      { 
       "type": "Action.OpenUrl", 
       "url": "http://foo.bar.com", 
       "title": "adaptivecards1" 
      } 
      ], 
     "items": [ 
      { 
       "type": "ColumnSet", 
       "separation": "strong", 
       "columns": [ 
        { 
         "type": "Column", 
         "size":1, 
         "items": [ 
          { 
           "type": "TextBlock", 
           "text": "Title", 
           "size": "large", 
           "isSubtle": true 
          }, 
          { 
           "type": "TextBlock", 
           "text": "Model: ABC", 
           "size": "small" 
          } 
         ] 
        }, 
        { 
         "type": "Column", 
         "size": "1", 
         "items": [ 
          { 
           "type": "TextBlock", 
           "text": " " 
          }, 
          { 
           "type": "Image", 
           "url": "https://path/to/image.jpg", 
           "size": "large", 
           "horizontalAlignment" :"right" 
          } 
         ] 
        } 
       ] 
      } 
     ] 
    }, 
    { 

     "style":"normal", 
     "type": "Container", 
     "separation" : "strong", 
     "actions": [ 
      { 
       "type": "Action. OpenUrl", 
       "url": "http://foo.bar.com", 
       "title": "adaptivecards2" 
      } 
      ], 
     "items": [ 
      { 
       "type": "ColumnSet", 
       "separation": "strong", 
       "columns": [ 
        { 
         "type": "Column", 
         "size":1, 
         "items": [ 
          { 
           "type": "TextBlock", 
           "text": "Another Title", 
           "size": "large", 
           "isSubtle": true 
          }, 
          { 
           "type": "TextBlock", 
           "text": "Model: XYZ", 
           "size": "small" 
          }       ] 
        }, 
        { 
         "type": "Column", 
         "size": "1", 
         "items": [ 
          { 
           "type": "TextBlock", 
           "text": " " 
          }, 
          { 
           "type": "Image", 
           "url": "https://path/to/other/image.jpg", 
           "size": "large", 
           "horizontalAlignment" :"right" 
          } 
         ] 
        } 
       ] 
      } 
     ] 
    } 
]} 
+0

不幸的是,这是我们的文档中的一个错误,容器当前没有操作。这是我们打算在未来访问的东西,但还没有具体的计划。文档将很快更新 –

回答

1

每本GitHub issue,似乎有在文档中的错误,而且actions属性不上Container存在。

相反,您应该将ActionSet类型的项添加到您的items阵列中,并列出actions

按照你的样品,它应该看起来像:

{ 
    "type": "AdaptiveCard", 
    "body": [ 
     { 
      "style": "normal", 
      "type": "Container", 
      "separation": "strong", 
      "items": [ 
       { 
        "type": "ActionSet", 
        "actions": [ 
         { 
          "type": "Action.OpenUrl", 
          "url": "http://foo.bar.com", 
          "title": "adaptivecards1" 
         } 
        ] 
       }, 
       { 
        "type": "ColumnSet", 
        "separation": "strong", 
        "columns": [ 
         { 
          "type": "Column", 
          "size": 1, 
          "items": [ 
           { 
            "type": "TextBlock", 
            "text": "Title", 
            "size": "large", 
            "isSubtle": true 
           }, 
           { 
            "type": "TextBlock", 
            "text": "Model: ABC", 
            "size": "small" 
           } 
          ] 
         }, 
         { 
          "type": "Column", 
          "size": "1", 
          "items": [ 
           { 
            "type": "TextBlock", 
            "text": " " 
           }, 
           { 
            "type": "Image", 
            "url": "https://path/to/image.jpg", 
            "size": "large", 
            "horizontalAlignment": "right" 
           } 
          ] 
         } 
        ] 
       } 
      ] 
     }, 
     { 
      "style": "normal", 
      "type": "Container", 
      "separation": "strong", 
      "items": [ 
       { 
        "type": "ActionSet", 
        "actions": [ 
         { 
          "type": "Action.OpenUrl", 
          "url": "http://foo.bar.com", 
          "title": "adaptivecards2" 
         } 
        ] 
       }, 
       { 
        "type": "ColumnSet", 
        "separation": "strong", 
        "columns": [ 
         { 
          "type": "Column", 
          "size": 1, 
          "items": [ 
           { 
            "type": "TextBlock", 
            "text": "Another Title", 
            "size": "large", 
            "isSubtle": true 
           }, 
           { 
            "type": "TextBlock", 
            "text": "Model: XYZ", 
            "size": "small" 
           } 
          ] 
         }, 
         { 
          "type": "Column", 
          "size": "1", 
          "items": [ 
           { 
            "type": "TextBlock", 
            "text": " " 
           }, 
           { 
            "type": "Image", 
            "url": "https://path/to/other/image.jpg", 
            "size": "large", 
            "horizontalAlignment": "right" 
           } 
          ] 
         } 
        ] 
       } 
      ] 
     } 
    ] 
} 

enter image description here

这还讨论了here