c# - 在复选框输入类型机器人框架c#中添加带有图像和文本块的列
问题描述
我正在使用 c# 在 bot 框架 v3 中开发自适应卡。我想要输入选择字段,每个选择选项都有一个图像和一个文本框。那么是否有可能实现它,如果可以,我们如何实现它,如下所示
试过的代码:
var choiceinput = new AdaptiveChoiceSetInput();
var Choices = new List<AdaptiveChoice>();
card.Body.Add(choiceinput);
Choices.Add();
解决方案
仅使用 ChoiceSets 无法实现您想要实现的目标。ChoiceSets 几乎是键值对。
但是,您可以使用 input.toggle 和 ColumnSets 的组合,如下所示:
{
"type": "AdaptiveCard",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"width": "10px",
"type": "Column",
"items": [
{
"type": "Input.Toggle"
}
],
"verticalContentAlignment": "Center"
},
{
"width": "45px",
"type": "Column",
"items": [
{
"type": "Image",
"style": "Person",
"url": "https://graph.facebook.com/1989019881113809/picture?type=large",
"width": "45px"
}
]
},
{
"width": "stretch",
"type": "Column",
"items": [
{
"text": "Jack Maa",
"type": "TextBlock",
"weight": "Bolder"
},
{
"text": "Advisor - Scale Prediction & Control",
"type": "TextBlock"
}
]
}
]
},
{
"type": "ColumnSet",
"columns": [
{
"width": "10px",
"type": "Column",
"items": [
{
"type": "Input.Toggle"
}
],
"verticalContentAlignment": "Center"
},
{
"width": "45px",
"type": "Column",
"items": [
{
"type": "Image",
"style": "Person",
"url": "https://graph.facebook.com/1989019881113809/picture?type=large",
"width": "45px"
}
]
},
{
"width": "stretch",
"type": "Column",
"items": [
{
"text": "Mayuresh Jaiswal",
"type": "TextBlock",
"weight": "Bolder"
},
{
"text": "Water Treatment Advisor",
"type": "TextBlock"
}
]
}
]
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1000.0"
}
最后一张卡片看起来像这样:
不过,我真的建议您看一下模板。直接在 C# 中构建复杂的卡片确实不是很好,而在这样的场景中,模板让你的事情变得更容易。
推荐阅读
- python-3.x - 将整数列表转换为字典
- java - 使用哈希图时 Gson 抛出错误
- python - Python,定义函数以生成从任务管理器程序跟踪的多个 txt 文件?
- python - Statsmodels 均值差异的置信区间
- android - 在 Android 应用中管理多种类型的 Firebase 推送通知
- r - 如何使用向量对 R 中的值进行分类?
- javascript - 我想在反应原生博览会中隐藏标题
- javascript - rollbackFailedOptional:动词 npm-session 9a5b1fb467359b45
- reactjs - 如何重定向到 /user/dashboard
- mysql - 使用带有 ifnull 函数 MySQL 的联合语句