Render a card - WinUI 3
Here's how to render a card using the WinUI 3 SDK.
Create an instance of your renderer
Create an instance of the renderer library.
using AdaptiveCards.Rendering.WinUI3;
// ...
var renderer = new AdaptiveCardRenderer();
Create a card from a JSON string
var card = AdaptiveCard.FromJsonString(jsonString);
Create a card from a JSON object
var card = AdaptiveCard.FromJson(jsonObject);
Render a card
Acquire a card from a source and render it.
RenderedAdaptiveCard renderedAdaptiveCard = renderer.RenderAdaptiveCard(card);
// Check if the render was successful
if (renderedAdaptiveCard.FrameworkElement != null)
{
// Get the framework element
var uiCard = renderedAdaptiveCard.FrameworkElement;
// Add it to your UI
myGrid.Children.Add(uiCard);
}
Example
Here is an example from the WinUI 3 renderer.
var renderer = new AdaptiveCardRenderer();
var card = AdaptiveCard.FromJsonString(jsonString);
var renderedAdaptiveCard = renderer.RenderAdaptiveCard(card.AdaptiveCard);
if (renderedAdaptiveCard.FrameworkElement != null)
{
myGrid.Children.Add(renderedAdaptiveCard.FrameworkElement);
}
...