Iciclecreek.AdaptiveCards.Rendering.Avalonia
1.0.4
dotnet add package Iciclecreek.AdaptiveCards.Rendering.Avalonia --version 1.0.4
NuGet\Install-Package Iciclecreek.AdaptiveCards.Rendering.Avalonia -Version 1.0.4
<PackageReference Include="Iciclecreek.AdaptiveCards.Rendering.Avalonia" Version="1.0.4" />
paket add Iciclecreek.AdaptiveCards.Rendering.Avalonia --version 1.0.4
#r "nuget: Iciclecreek.AdaptiveCards.Rendering.Avalonia, 1.0.4"
// Install Iciclecreek.AdaptiveCards.Rendering.Avalonia as a Cake Addin #addin nuget:?package=Iciclecreek.AdaptiveCards.Rendering.Avalonia&version=1.0.4 // Install Iciclecreek.AdaptiveCards.Rendering.Avalonia as a Cake Tool #tool nuget:?package=Iciclecreek.AdaptiveCards.Rendering.Avalonia&version=1.0.4
Adaptive Cards Rendering library for Avalonia UI
This library renders adaptive cards using AvaloniaUI controls.
(Option 1) Use AdaptiveCardView control
Sample Model
public class CardModel
{
public AdaptiveCard Card { get; set; }
}
Add namespace
xmlns:ac="using:AdaptiveCards.Rendering.Avalonia"
Insert an AdaptiveCardView control bound to the card:
<ac:AdaptiveCardView Card="{Binding Card}" Width="600" />
Produces a rendered card like this:
Handling Actions
Actions are supported by the library, but you must provide a handler for the Action.Execute and Action.Submit actions. To do that with the AdaptiveCardView you simply need to handle the Action event. The event will be fired for all actions, so you will need to check the type of the action and handle it accordingly. It is a routed event, so you can add the route handler at any level of the visual tree.
<ac:AdaptiveCardView Card="{Binding Card}" Width="600" Action="OnAdaptiveAction" />
And the action handler
public static async void OnAdaptiveAction(Window window, object? sender, RoutedAdaptiveActionEventArgs e)
{
if (e.Action is AdaptiveOpenUrlAction openUrlAction)
{
Process.Start(new ProcessStartInfo(openUrlAction.Url.AbsoluteUri) { UseShellExecute = true });
e.Handled = true;
}
else if (e.IsDataAction())
{
// handle Action.Execute or Action.Submit
....
e.Handled = true;
}
}
Usage: (Option 2) Use AdaptiveCardRenderer directly
You can call the renderer directly
var renderer = new AdaptiveCardRenderer(hostConfig);
var renderedCard = renderer.RenderCard(adaptiveCard);
renderedCard.OnAction += (sender, e) =>
{
// handle event...
};
// add element to visual tree
grid.Children.Add(renderedCard.Control);
Supported AdaptiveCard Schema
This library suppports all functionality for 1.5 of Adaptive Card schemas, and should work on all Avalonia platforms with following exceptions:
Feature | Schema Version | Platform | Parsing | Rendering |
---|---|---|---|---|
Action.OpenUrl | v1.0 | All | ✅ | ✅ |
Action.ShowCard | v1.0 | All | ✅ | ✅ |
Action.Submit | v1.0 | All | ✅ | ✅ |
Column | v1.0 | All | ✅ | ✅ |
ColumnSet | v1.0 | All | ✅ | ✅ |
Container | v1.0 | All | ✅ | ✅ |
Fact | v1.0 | All | ✅ | ✅ |
FactSet | v1.0 | All | ✅ | ✅ |
Image | v1.0 | All | ✅ | ✅ |
ImageSet | v1.0 | All | ✅ | ✅ |
Input.ChoiceSet | v1.0 | All | ✅ | ✅ |
Input.Date | v1.0 | All | ✅ | ✅ |
Input.Number | v1.0 | All | ✅ | ✅ |
Input.Text | v1.0 | All | ✅ | ✅ |
Input.Time | v1.0 | All | ✅ | ✅ |
Input.Toggle | v1.0 | All | ✅ | ✅ |
SelectAction | v1.0 | All | ✅ | ✅ |
TextBlock | v1.0 | All | ✅ | ✅ |
Explicit Image Dimension | v1.1 | All | ✅ | ✅ |
Background Color | v1.1 | All | ✅ | ✅ |
Media | v1.1 | Windows,MacOS,Linux | ✅ | ✅ |
Vertical Content Alignment | v1.1 | All | ✅ | ✅ |
Action Icon | v1.1 | All | ✅ | ✅ |
Action Style | v1.2 | All | ✅ | ✅ |
Toggle Visibility | v1.2 | All | ✅ | ✅ |
ActionSet | v1.2 | All | ✅ | ✅ |
Fallback | v1.2 | All | ✅ | ✅ |
Container BackgroundImage | v1.2 | All | ✅ | ✅ |
Container MinHeight | v1.2 | All | ✅ | ✅ |
Container Bleed | v1.2 | All | ✅ | ✅ |
Container Style | v1.2 | All | ✅ | ✅ |
Image Data Uri | v1.2 | All | ✅ | ✅ |
Action Icon Data Uri | v1.2 | All | ✅ | ✅ |
Input.Text Inline Action | v1.2 | All | ✅ | ✅ |
TextBlock FontType | v1.2 | All | ✅ | ✅ |
RichTextBlock | v1.2 | All | ✅ | ✅ |
Input Label | v1.3 | All | ✅ | ✅ |
Input ErrorMessage | v1.3 | All | ✅ | ✅ |
AssociatedInputs | v1.3 | All | ✅ | ✅ |
RichTextBlock UnderLine | v1.3 | All | ✅ | ✅ |
Action.Refresh | v1.4 | All | ✅ | ✅ |
AdaptiveCard Authentication | v1.4 | All | ✅ | ✅ |
Action.Execute | v1.4 | All | ✅ | ✅ |
Action IsEnabled | v1.5 | All | ✅ | ✅ |
Action Mode | v1.5 | All | ✅ | ✅ |
Action/SelectAction ToolTip | v1.5 | All | ✅ | ✅ |
Input.ChoiceSet Filtered Style | v1.5 | All | ✅ | ✅ |
Input.Text Password Style | v1.5 | All | ✅ | ✅ |
TextBlock Heading Style | v1.5 | All | ✅ | ✅ |
RTL | v1.5 | All | ✅ | ✅ |
Table | v1.5 | All | ✅ | ✅ |
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- AdaptiveCards (>= 3.1.0)
- AsyncImageLoader.Avalonia (>= 3.2.1)
- Avalonia (>= 11.1.1)
- Avalonia.Markup.Xaml.Loader (>= 11.1.1)
- Avalonia.ReactiveUI (>= 11.1.1)
- Avalonia.Svg (>= 11.1.0)
- Iciclecreek.Avalonia.Controls.Media (>= 1.0.5)
- SkiaSharp.Svg (>= 1.60.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.4 | 95 | 8/2/2024 |