🌐 繁體中文 | English
A WPF desktop tool for browsing SVG files and converting them to XAML for use in .NET projects.
Forked from BerndK/SvgToXaml with custom enhancements for a modern dark-themed workflow.
Try it online — no installation needed
A pure frontend web app (React + TypeScript) that runs entirely in the browser. Drag & drop SVG files, preview them, and convert to XAML instantly. Supports both Geometry and DrawingImage output modes, batch export to ResourceDictionary / UserControl / ZIP.
- SVG Browser — Open a folder and instantly preview all SVG icons in a resizable grid
- Three Output Modes — Choose how SVGs are emitted to XAML:
- Button Style (default) — Full
Buttontemplate withIsMouseOver/IsPressedtriggers, ready to drop in as a clickable icon button - Geometry Style — Pure
ContentControlicon template; color controlled externally viaForeground - DrawingImage — Automatic fallback for complex SVGs containing gradients or clip paths
- Button Style (default) — Full
- Click to Copy — Single-click any icon to copy its XAML to the clipboard with a toast notification (default mode is configurable in Settings)
- Settings — In-app settings window (toolbar gear icon):
- Default left-click action — Button Style vs Geometry Style, with side-by-side example XAML in the help tooltip
- Design Tokens — define your project's color tokens once; SVG colors that match a token are emitted as
{StaticResource TokenKey}instead of generating a per-iconSolidColorBrush. Manage tokens via inline DataGrid, Import from XAML (merge into existing list), or Edit XAML (open the full token set as aResourceDictionaryand edit it directly — saving replaces the whole list). Tokens are auto-sorted by key. - Settings persist across version updates (auto-migrated from the previous user.config on first launch of a new version).
- Detail View — Inspect preview, design size, actual size, stretch mode, raw XAML, and SVG source
- Background Toggle — Switch preview background between dark gray, light gray, and checkerboard
- Auto Refresh —
FileSystemWatchermonitors the folder and refreshes automatically when files change - i18n — Toggle between English and Traditional Chinese (zh-TW); preference is persisted
- Batch Export — Convert an entire folder of SVGs into a single XAML
ResourceDictionary(Design Tokens are applied here too) - Drag & Drop — Drop a folder to browse it, or drop a file to open the detail view
- Dark Theme — Modern dark UI powered by HandyControl, with custom-styled context menus, tooltips, and scrollbars
- Auto-Update Check — On launch, queries the latest GitHub release; a button appears in the toolbar when a newer version is available
Go to Releases and download SvgToXaml.exe — run directly, no installation or extraction needed.
Prerequisites: Visual Studio 2022 with .NET Framework 4.6.2 targeting pack.
git clone https://github.com/howwmingnew/SvgToXaml.git
cd SvgToXaml
nuget restore SvgToXaml.sln
msbuild SvgToXaml.sln /p:Configuration=ReleaseOutput: SvgToXaml\bin\Release\SvgToXaml.exe
- Launch
SvgToXaml.exe - Open a folder via the toolbar button, address bar, or drag & drop
- Browse icons — resize with the slider, toggle background, switch language
- Single-click (or double-click) any icon to copy its XAML to the clipboard — the output format follows your Default left-click action setting
- Click the gear icon in the toolbar to open Settings — switch the default copy mode or manage Design Tokens
- Right-click for context menu: copy XAML, view detail, open file
If your WPF project already defines named brushes (e.g. Brand.Primary), you can register them in Settings → Design Tokens so SVG colors that match are emitted as references instead of inline brushes.
Given a token Brand.Primary = #FF0066CC and an SVG that uses #0066CC (alpha-less colors are treated as #FF0066CC):
<!-- Without tokens -->
<SolidColorBrush x:Key="home_Brush" Color="#FF0066CC" />
<Path Fill="{StaticResource home_Brush}" ... />
<!-- With token -->
<Path Fill="{StaticResource Brand.Primary}" ... />Tokens are stored in %APPDATA%\SvgToXaml\design-tokens.txt and applied to both click-to-copy and folder export.
SvgToXaml.exe doubles as a CLI for automation pipelines and AI agent integration — for example feeding Figma-exported SVGs through Claude Code, MCP workflows, or CI/CD. Two commands are available.
Convert one SVG (or every SVG in a folder) and emit XAML to a file, a folder, or stdout.
# Single file → stdout (default format: geometry)
SvgToXaml.exe Convert /input icon.svg
# Single file → specific output file
SvgToXaml.exe Convert /input icon.svg /output icon.xaml
# Choose output format
SvgToXaml.exe Convert /input icon.svg /format button # Button + hover/pressed triggers
SvgToXaml.exe Convert /input icon.svg /format drawingimage # Legacy DrawingImage
# Folder batch → output folder
SvgToXaml.exe Convert /input ./icons /output ./xaml /recurse
# Folder batch → stdout (each file separated by `<!-- ===== filename ===== -->`)
SvgToXaml.exe Convert /input ./icons
# Read SVG from stdin — no temp file needed (great for piping curl/Figma asset URLs)
curl -s "https://example.com/icon.svg" | SvgToXaml.exe Convert /input - /name brushOutput formats:
geometry(default) —Path-basedContentControlstyle, recolorable viaForegroundbutton— FullButtonstyle withIsMouseOver/IsPressedtriggersdrawingimage— LegacyDrawingImage(also the automatic fallback when an SVG contains gradients or clip paths)
Inputs:
- File path — single SVG (
.svg/.svgz) - Folder path — batch convert every SVG inside (
/recurseto descend) -(dash) — read SVG content from stdin; pair with/name <baseName>so resource keys are meaningful (defaults toIconif omitted)
Streams:
- stdout — pure XAML (when
/outputis omitted) - stderr — banner, warnings, write confirmations, errors
Exit codes: 0 success · 1 IO / conversion error · 2 invalid arguments
Note: SvgToXaml is a Windows GUI app (WinExe). When invoking from PowerShell, Bash, or any non-
cmdshell, wrap the call withcmd /c "..."so the parent process waits for completion and stdout redirection captures the output.
SvgToXaml.exe BuildDict /inputdir:".\svg" /outputname:icons /outputdir:"."
Produces icons.xaml — a ResourceDictionary you can merge into your app:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="icons.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>Then reference an icon:
<Path Data="{StaticResource cloud_iconGeometry}" Fill="{Binding Foreground}" />SvgToXaml.exe /? # list all commands
SvgToXaml.exe Convert /? # parameter details for Convert
SvgToXaml.exe BuildDict /? # parameter details for BuildDict
| Component | Technology |
|---|---|
| Framework | WPF (.NET Framework 4.6.2) |
| Language | C# + XAML |
| SVG Engine | SharpVectors |
| UI Toolkit | HandyControl |
| Code Editor | AvalonEdit |
| CI/CD | GitHub Actions (auto-build on tag push) |
| Web Version | React 18 + TypeScript + Vite + Tailwind CSS |
SvgToXaml/ # Main WPF application
Infrastructure/ # LanguageManager, FolderPicker, utilities
Localization/ # Strings.en.xaml, Strings.zh-TW.xaml
ViewModels/ # MVVM view models
Themes/ # CustomStyles.xaml (dark theme)
Explorer/ # Folder tree control
SvgConverter/ # Core SVG-to-XAML conversion library
SvgConverterTest/ # Unit tests
WpfDemoApp/ # Demo application
svg-to-xaml-web/ # Web version (React + TypeScript)
Based on BerndK/SvgToXaml. See original repository for license details.