如何将字符串数组绑定到 TextBlock?
How can an array of strings be bound to a TextBlock?
我正在阅读 Template Language documentation and saw that it's possible to use an array of strings to replicate a TextBlock element multiple times using the syntax "text": "${$data}
. However, when I try to replicate this in the online Designer,我没有得到预期的结果。
我尝试使用文档中描述的构造:
{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "large",
"weight": "bolder",
"text": "Names"
},
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"$data": [
"Matt",
"David",
"Thomas"
],
"text": "${$data}"
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.3"
}
What gets displayed
如有任何帮助,我们将不胜感激。谢谢!
更新
我没有意识到 Designer 提供了单独的预览模式来显示这些类型的动态数据注入。当您启用预览模式时,数据会按预期动态显示。一个示例是当您打开设计器时加载的默认卡片 - 在您启用预览模式之前不会填充 FactSet。
进入预览模式前的默认卡片:
进入预览模式后的默认卡片:
下面是旧答案
回答我自己的问题 - Designer 似乎不支持显示这种结构。我尝试将带有上述 JSON 的卡片添加到我的 .NET 项目中,它在 Bot Framework Emulator 中完美显示。
我正在阅读 Template Language documentation and saw that it's possible to use an array of strings to replicate a TextBlock element multiple times using the syntax "text": "${$data}
. However, when I try to replicate this in the online Designer,我没有得到预期的结果。
我尝试使用文档中描述的构造:
{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "large",
"weight": "bolder",
"text": "Names"
},
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"$data": [
"Matt",
"David",
"Thomas"
],
"text": "${$data}"
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.3"
}
What gets displayed
如有任何帮助,我们将不胜感激。谢谢!
更新
我没有意识到 Designer 提供了单独的预览模式来显示这些类型的动态数据注入。当您启用预览模式时,数据会按预期动态显示。一个示例是当您打开设计器时加载的默认卡片 - 在您启用预览模式之前不会填充 FactSet。
进入预览模式前的默认卡片:
进入预览模式后的默认卡片:
下面是旧答案
回答我自己的问题 - Designer 似乎不支持显示这种结构。我尝试将带有上述 JSON 的卡片添加到我的 .NET 项目中,它在 Bot Framework Emulator 中完美显示。