SvgML.Avalonia lets you author an SVG element tree directly in Avalonia XAML. Instead of loading an external .svg file, you declare svg, rect, g, gradients, filters, text, foreignObject, and related nodes inline, and the package serializes that tree back through the shared Svg.Skia loading pipeline.
The NuGet package name is SvgML.Avalonia, while the CLR namespace exposed to Avalonia XAML remains SvgML.
dotnet add package SvgML.Avalonia
foreignObject to place real Avalonia controls inside text flow or scene geometry,Svg.Skia runtime.| Type | Role |
|---|---|
SvgML.svg |
Root Avalonia control that owns the inline SVG tree and renders it |
SvgML.element |
Base class for generated SVG element controls |
SvgML.elements |
Child collection for nested SVG nodes |
SvgML.content |
Text-content backing node used by text-related nodes; authored XAML can normally use literal text |
SvgML.foreignObject |
SVG-native host for an Avalonia Control inside text flow or scene geometry |
<Window
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<svg Width="160"
Height="160"
viewBox="0 0 100 100">
<rect width="100"
height="100"
fill="#F3F4F6" />
<circle cx="50"
cy="50"
r="30"
fill="#0EA5E9"
stroke="#0F172A"
stroke-width="4" />
</svg>
</Window>
The element/property naming stays close to SVG authoring, so attributes such as stroke-width, fill-opacity, and viewBox can stay readable in XAML.
The root svg control:
Picture for direct SKPicture access,HitTestElements(...), HitTestSceneNodes(...), and TryGetPicturePoint(...),SvgElement and retained scene-node results back to the originating inline controls.That makes the package useful for interactive icons, small diagrams, templated visuals, and editor-like overlays where authored markup and rendered output both need to stay available.
foreignObject is the public hosted-control API. It can be used inline in text/tspan or as a normal SVG scene element under svg or g.
<svg Height="220" Stretch="Uniform" viewBox="0 0 360 160">
<text x="24" y="48" fill="#334155" style="font-size:16px;">
<tspan>Open </tspan>
<foreignObject width="120" height="34">
<Button Content="Preview" MinWidth="120" />
</foreignObject>
<tspan> in review mode.</tspan>
</text>
</svg>
The native control is hosted by the Avalonia visual tree while the SVG surface continues to render through Svg.Skia. See SvgML foreignObject Controls for cross-platform sizing and layout rules.
Because the SVG tree is made of Avalonia controls, normal Avalonia selectors and animations can target those elements.
<Style Selector=":is(rect)[id=accent-bar]">
<Style.Animations>
<Animation Duration="0:0:1.2"
IterationCount="Infinite"
PlaybackDirection="Alternate">
<KeyFrame Cue="0%">
<Setter Property="x" Value="0%" />
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="x" Value="85%" />
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
For fuller examples, see SvgML.Avalonia Inline SVG, SvgML foreignObject Controls, and the samples/SvgML.Avalonia.Demo project in the repository.
SvgSource.Svg.Skia runtime path.