2017-08-01 87 views
1

我需要显示格式化文本在HeroCard设置文本格式

card = new HeroCard 
      { 
       Title = taskEntity.SourceEntityName + " : " + taskEntity.SourceEntityInstanceName, 
       Subtitle = taskEntity.Description + " : " + $"{taskEntity.CreatedOn:D}", 
       Text = await GetDetails(taskEntity), 
       Buttons = new List<CardAction> 
       { 
        new CardAction {Value = "Approve " + taskEntity.Id, Title = "Approve", Type = ActionTypes.PostBack}, 
        new CardAction {Value = "Reject " + taskEntity.Id, Title = "Reject", Type = ActionTypes.PostBack} 
       } 
      }; 

GetDetails通过让每个细节都在使用它“Environment.NewLine”返回格式化字符串“\ r \ n”一条新的线但它不起作用。有没有使用自适应卡的方法?

编辑: 1.我测试的渠道是Skype的

+0

哪一个是你在使用“IT渠道不起作用“? –

+0

在Skype上不起作用。 – Ash

回答

1

不是'\r\n'请尝试'\n\n'。在Skype的机器人,你也可以用'<br/>'

这里既是一个例子:

if (length > 0 && activity.Text == "hero") 
{ 
    var reply = ((Activity)context.Activity).CreateReply(string.Empty); 
    reply.Attachments = new List<Attachment>(); 
    var heroCard = new HeroCard() 
     { 
      Text = "1)Hero Card Text\n\n2)next line!\n\n3)and another new line!" 
     }; 
    reply.Attachments.Add(heroCard.ToAttachment()); 
    await context.PostAsync(reply); 
} 
else if (length > 0 && activity.Text == "hero html") 
{ 
    var reply = ((Activity)context.Activity).CreateReply(string.Empty); 
    reply.Attachments = new List<Attachment>(); 
    var heroCard = new HeroCard() 
     { 
      Text = "Hero Card Text <br/>next line!", 
     }; 
    reply.Attachments.Add(heroCard.ToAttachment()); 
    await context.PostAsync(reply); 
} 

,结果在Skype的:

enter image description here

+0

谢谢,这个工程。 – Ash

相关问题