XAML SVG Icons

By the Axialis Engineering team ·

XAML SVG Icons

Bitmap icons go blurry on high-DPI displays and break when a WPF or WinUI app switches between light and dark themes. The fix is to ship icons as XAML Path geometry: vector data that stays crisp at any DPI and recolors itself when the theme changes. This guide exports that geometry from IconVectors and wires it into your app — binding Fill and Foreground to brushes, labelling icons with AutomationProperties.Name, and packaging the paths as a reusable ResourceDictionary.

When to choose XAML code

Draw, Import or Trace your icon

The IconVectors editor with a heart icon drawn on a 24-pixel grid, ready to export as XAML Path geometry

Export XAML from IconVectors

  1. Design on a consistent grid (e.g. 24×24). Keep strokes aligned to whole pixels so the geometry snaps cleanly at 100% scale.
  2. Decide your theming strategy. For single-color icons, bind Fill or Stroke to a brush rather than baking in a hex value — that is what lets the icon follow the theme (see below).
  3. Open the Live Code Viewer (F3) and switch to the XAML tab to see the generated Path markup.
  4. Copy the geometry string or the full Path and paste it into your app as shown next.

WPF: simple Path bound to Foreground

<Grid>
  <Grid.Resources>
    <Style x:Key="IconPathStyle" TargetType="Path">
      <Setter Property="Stretch" Value="Uniform"/>
      <Setter Property="Fill" Value="{Binding Foreground, RelativeSource={RelativeSource AncestorType=Control}}"/>
      <Setter Property="SnapsToDevicePixels" Value="True"/>
    </Style>
  </Grid.Resources>

  <Button Padding="8">
    <Path Style="{StaticResource IconPathStyle}"
          Width="24" Height="24"
          Data="M2.5 9C2.5 2.5 10 3 12 7.5C14 3 21.5 2.5 21.5 9C21.5 15.4 12 21.5 12 21.5C12 21.5 2.5 15.6 2.5 9z"
          AutomationProperties.Name="Favorite"/>
    <Button.Content>Favorite</Button.Content>
  </Button>
</Grid>

WPF: package as a reusable resource (Geometry)

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <SolidColorBrush x:Key="IconBrush" Color="#2563EB"/>
  <Geometry x:Key="Heart24Geometry">M2.5 9C2.5 2.5 10 3 12 7.5C14 3 21.5 2.5 21.5 9C21.5 15.4 12 21.5 12 21.5C12 21.5 2.5 15.6 2.5 9z</Geometry>
</ResourceDictionary>
<Path Data="{StaticResource Heart24Geometry}"
      Width="24" Height="24"
      Stretch="Uniform"
      Fill="{DynamicResource IconBrush}"
      AutomationProperties.Name="Favorite"/>

WinUI: PathIcon with themeable brush

<Page.Resources>
  <SolidColorBrush x:Key="IconBrush" Color="{ThemeResource SystemAccentColor}" />
</Page.Resources>

<StackPanel Orientation="Horizontal" Spacing="8">
  <PathIcon Data="M2.5 9C2.5 2.5 10 3 12 7.5C14 3 21.5 2.5 21.5 9C21.5 15.4 12 21.5 12 21.5C12 21.5 2.5 15.6 2.5 9z"
            Foreground="{StaticResource IconBrush}"
            Width="24" Height="24"
            AutomationProperties.Name="Favorite"/>
  <TextBlock Text="Favorite"/>
</StackPanel>

Accessibility checklist

Theming options (brushes & bindings)

Performance & packaging tips

Reference example (XAML Path)

<Path Width="24" Height="24" Stretch="Uniform"
      StrokeThickness="1" StrokeLineJoin="Round" StrokeStartLineCap="Round" StrokeEndLineCap="Round"
      Data="M2.5 9C2.5 2.5 10 3 12 7.5C14 3 21.5 2.5 21.5 9C21.5 15.4 12 21.5 12 21.5C12 21.5 2.5 15.6 2.5 9z"
      Fill="{DynamicResource IconBrush}"
      AutomationProperties.Name="Favorite"/>

Related guides

Start Making SVG Icons Today with IconVectors

Download the fully-functional 30‑Day Free Trial and unlock your icon design workflow.

Version 1.70 for Windows and macOS