🎯 Avalonia Templates for VS Code
Generate fully-structured Avalonia UI components with one click. No more boilerplate. Just clean, scalable code.
 
 

A powerful VS Code extension that automates the creation of Avalonia UI components — including Window, UserControl, TemplatedControl, Styles, and ResourceDictionary — with proper namespace handling, directory structure, automatic using statements, and real-time logging.
Perfect for developers building cross-platform desktop apps with Avalonia UI in C# and XAML.
🚀 Features
✨ Core Template Generation
| Feature | Description | 
| Window | Creates a complete Window.axaml+WindowViewModel.cswith proper inheritance fromViewModelBase. | 
| UserControl | Generates UserControl.axaml+ matching ViewModel with correct namespace & folder structure. | 
| TemplatedControl | Boilerplate-ready templated control with TemplatePartattributes and default style. | 
| Styles | Auto-generates Styles.axamlwith theme-aware resource definitions. | 
| ResourceDictionary | Clean, isolated ResourceDictionary.axamlfiles with optional namespace setup. | 
🔧 Advanced Automation
- Smart Namespace Detection: Automatically detects project root and applies correct namespaces based on folder hierarchy.
- Automatic usingStatements: Adds only the necessaryusingdirectives for Avalonia and your project’s ViewModel base class — no clutter.
- Folder Structure Preservation: Creates ViewModels in /ViewModels/subfolder, matching your project’s layout.
- Configurable Logging: Control verbosity with avaloniaTemplates.logLevel(debug,info,warn,error,none).
📊 Real-Time Diagnostics
- Built-in singleton logger with color-coded output in VS Code's Output Panel.
- Real-time progress tracking during template generation.
- Detailed error messages with actionable suggestions.
💡 No more guessing which namespace to use or where to put the file. The extension knows your project structure.
🖼️ Preview
📹 Watch how it works in action:
➤ Creating a Window

➤ Creating an UserControl

⚙️ Configuration
Customize logging behavior via VS Code settings:
{
  "avaloniaTemplates.logLevel": "info"
}
Available levels:
- debug— All logs (ideal for development)
- info— Default — Shows creation steps
- warn— Only warnings and errors
- error— Critical issues only
- none— Silent mode
💬 To access settings: Ctrl+Shift+P → “Preferences: Open Settings (JSON)”
🛠️ Installation
- Open VS Code.
- Go to Extensions (Ctrl+Shift+X).
- Search for “Avalonia Templates” by ADdy2142.
- Click Install.
✅ Requirements:
- VS Code 1.91+
- An existing Avalonia project (with .axamlfiles)
- .NET SDK installed
🔍 Extension activates automatically when you open any .axaml file or have one in your workspace.
📂 Generated Structure Example
👉 Window Example
When creating a Window named MainWindow inside Views/:
MyAvaloniaApp/
├── Views/
│   └── MainWindow.axaml
├── ViewModels/
│   └── MainWindowViewModel.cs ← Auto-generated!
└── ...
MainWindowViewModel.cs includes:
using System;
namespace MyAvaloniaApp.ViewModels; // ✅ Correct namespace!
public class MainWindowViewModel : ViewModelBase // ✅ Inherited!
{
    public MainWindowViewModel()
    {
        // Initialize properties here
    }
}
👉 UserControl Example
When creating a UserControl named SomeUserControl inside Views/UserControls/:
MyAvaloniaApp/
├── Views/
│   └── UserControls/
│       └── SomeUserControl.axaml
├── ViewModels/
│   └── UserControls/
│       └── SomeUserControlViewModel.cs   ← Auto-generated!
└── ...
SomeUserControlViewModel.cs includes:
using System;
using MyAvaloniaApp.ViewModels; // ✅ Auto using statement!
namespace MyAvaloniaApp.ViewModels.UserControls; // ✅ Correct nested namespace!
public class SomeUserControlViewModel : ViewModelBase // ✅ Inherited!
{
    public SomeUserControlViewModel()
    {
        // Initialize properties or commands here
    }
}
💡 The extension automatically detects if you're creating a UserControl in a subfolder like /Views/UserControls/ and mirrors the structure in /ViewModels/UserControls/ — keeping your MVVM architecture clean and scalable.
📜 Change Log
See full details in CHANGELOG.md
🤝 Contributing
Found a bug? Have a feature request?
👉 Open an Issue on GitHub
👨💻 Pull requests are welcome!
📄 License
This project is licensed under the AGPL-3.0-only license — see LICENSE for details.
   
  
  Made with ❤️ for Avalonia Developers