可点击的HeroCard图像 [英] Clickable HeroCard images

查看:72
本文介绍了可点击的HeroCard图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎找不到任何文档或论坛的答案来制作可点击HeroCard中的图像.我希望能够单击图像并执行与使用按钮相同的imBack()操作.

I can't seem to find any documentation or forum answers to making an image in a HeroCard clickable. I want to be able to click the image and perform the same imBack() action as I would with a button.

推荐答案

您可以使用HeroCardTap属性来使Hero卡的图像通过该链接.

You can make the Hero card's image to go that link by using the Tap property of the HeroCard.

在C#中发布一些示例代码:

Posting some sample code in C#:

using System;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;
using System.Collections.Generic;

namespace Bot_Application2.Dialogs
{
    [Serializable]
    public class RootDialog : IDialog<object>
    {
        public async Task StartAsync(IDialogContext context)
        {
            context.Wait(ConversationStartedAsync);
        }

        public async Task ConversationStartedAsync(IDialogContext context, IAwaitable<IMessageActivity> argument)
        {
            IMessageActivity reply = context.MakeMessage();

            HeroCard heroCard = new HeroCard()
            {
                Title = "I'm a hero card",
                Images = new List<CardImage>
                {
                new CardImage(url: $"https://www.google.org/assets/static/images/logo_googledotorg-171e7482e5523603fc0eed236dd772d8.svg")
                },
                Tap = new CardAction()
                {
                    Value = $"https://www.google.co.in/",
                    Type = "openUrl",
                }
            };

            reply.Attachments = new List<Attachment>
                {
                    heroCard.ToAttachment()
                };

            await context.PostAsync(reply);
        }
    }
}

这篇关于可点击的HeroCard图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆