2017-08-01 88 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

相關問題