Clickable HeroCard images

大憨熊 提交于 2019-12-11 15:15:06

问题


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.


回答1:


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

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);
        }
    }
}




回答2:


It's not possible with a HeroCard. You might want to explore AdaptiveCards which allows that.



来源:https://stackoverflow.com/questions/45283764/clickable-herocard-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!