简体   繁体   中英

Change separator property of a adaptive card bot framework

I'm using Separator attribute in my textblock of adaptive card, property is working but i need to update the Thickness and line color of Separator below is the code, but its not getting reflected. I'm using bot framework v3

SeparatorConfig separatorConfig = new SeparatorConfig();

separatorConfig.LineThickness = 2;
separatorConfig.LineColor = "Black";

card.Body.Add(new AdaptiveTextBlock()
{
    Text = QuestionValue,
    Size = AdaptiveTextSize.Default,
    Weight = AdaptiveTextWeight.Bolder,
    Wrap = true,
    Separator = true,                                        
});

Just on a side note, the answer from Kyle is correct, you can't change the separators if you're not the one rendering the card.

Just on your code sample there, you should really learn about Adaptive Card templating. https://docs.microsoft.com/en-us/adaptive-cards/templating/

it makes the whole story so much easier.

First, you need to understand the purpose of Adaptive Cards. When you author an Adaptive Card, you intentionally give up a lot of control about how that card is going to look. This is because Adaptive Cards are meant to adapt to their environments, so that they look like they belong in whatever application is rendering them. The control you're trying to have over the separator is actually one of those things that's not up to the card author, but instead up to the card renderer .

Second, you need to consider some red flags in your code. The AdaptiveCards library you're using actually contains code that can be used by card authors as well as code that can be used by card renderers. The SeparatorConfig class is in the AdaptiveCards.Rendering namespace, which implies that it's meant to be used by renderers. Also notice that while you're creating the SeparatorConfig object and assigning values to its properties, you're not actually passing it into the AdaptiveTextBlock or doing anything with it at all.

You can only configure the separator if you have control over the client application. If you're using someone else's client application like Microsoft Teams then you have to accept that the separator's appearance is not yours to configure. If you're making your own client application then you can customize the separator using HostConfig .

See my latest blog post for more information about Adaptive Cards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM