formatting-wpf-csharp-code
/formatting-wpf-csharp-code
Formats WPF XAML and C# code using XamlStyler and dotnet format. Generates Settings.XamlStyler and .editorconfig files automatically. Use when code formatting or style cleanup is needed.
- Author
- christian289 ↗
- Repository
- dotnet-with-claudecode ↗
- Licence
- MIT
- Last repository change
- 21.07.2026
Assessment and security
- Files in this package
- 3
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 3
No signals detected. Repository changed on 21.07.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Formats WPF XAML and C# code using XamlStyler and dotnet format. Generates Settings.XamlStyler and .editorconfig files automatically. Use when code formatting or style cleanup is needed.
Original author description
Formats WPF XAML and C# code using XamlStyler and dotnet format. Generates Settings.XamlStyler and .editorconfig files automatically. Use when code formatting or style cleanup is needed.
How it works
- 1. Required Tools
- 2. Configuration Files
- 3. Formatting Commands
- 4. Workflow
- 5. Notes
- 6. References
SKILL.md preview
---
description: Formats WPF XAML and C# code using XamlStyler and dotnet format. Generates Settings.XamlStyler and .editorconfig files automatically. Use when code formatting or style cleanup is needed.
user-invocable: false
---
# WPF and C# Code Formatting
Applies consistent code style to XAML and C# files.
---
## 1. Required Tools
### .NET 10 SDK
All commands use `dotnet dnx` for cross-platform compatibility (Windows, Linux, macOS).
```bash
# Verify .NET 10 is available
dotnet --version # Should be 10.0.x or higher
```
### XamlStyler (XAML Formatting)
Run via `dotnet dnx` (dotnet tool runner). No manual installation required.
### dotnet format (C# Formatting)
Included with .NET SDK by default.
---
## 2. Configuration Files
### Settings.XamlStyler
Copy from template to workspace root if `Settings.XamlStyler` doesn't exist.
**Template location**: `templates/Settings.XamlStyler`
**Key settings**:
- `AttributesTolerance: 1` - Allow up to 1 attribute on same line
- `KeepFirstAttributeOnSameLine: true` - Keep first attribute on element line
### .editorconfig
Copy from template to workspace root if `.editorconfig` doesn't exist.
**Template location**: `templates/.editorconfig`
**Key settings**:
- Indentation: 4 spaces
- Line ending: CRLF (Windows)
- Max line length: 120
---
## 3. Formatting Commands
### XAML Formatting
```bash
# Format all XAML files in workspace
dotnet dnx -y XamlStyler.Console -- -d "{workspace}" -r -c "{workspace}/Settings.XamlStyler"
# Format single file
dotnet dnx -y XamlStyler.Console -- -f "{file.xaml}" -c "{workspace}/Settings.XamlStyler"
```
**dotnet dnx Options**:
- `-y`: Auto-accept confirmation prompt
- `--`: Separator between dnx options and tool arguments
**XamlStyler Options**:
- `-d`: Target directory
- `-f`: Target file
- `-r`: Recursive processing
- `-c`: Configuration file path
### C# Formatting
```bash
# Format entire solution
dotnet format "{solution.sln}" --no-restore
# Format specific project only
dotnet format "{project.csproj}" --no-restore
# Format single file
dotnet format "{project.csproj}" --include "{file.cs}" --no-restore
```
**Options**:
- `--no-restore`: Skip NuGet restore (faster)
- `--include`: Target specific file
---
## 4. Workflow
### Full Formatting
```
Task Progress:
- [ ] Step 1: Check if Settings.XamlStyler exists, create if not
- [ ] Step 2: Check if .editorconfig exists, create if not
- [ ] Step 3: Run dotnet dnx XamlStyler.Console for XAML formatting
- [ ] Step 4: Run dotnet format for C# formatting
```
### Per-file Formatting (Hook Usage)
```
- When .xaml file modified: Run dotnet dnx XamlStyler.Console
- When .cs file modified: Run dotnet format
```
---
## 5. Notes
- **Check git status**: Verify uncommitted changes before formatting
- **Binary exclusion**: bin/, obj/ folders automatically excluded
- **Encoding**: UTF-8 with BOM maintained (Visual Studio compatible)
---
## 6. References
- [XamlStyler GitHub](https://github.com/Xavalon/XamlStyler)
- [dotnet format Documentation](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-format)
- [.editorconfig Specification](https://editorconfig.org/)
Files in this package (3)
- SKILL.md 3 KB
- templates/.editorconfig 5 KB
- templates/Settings.XamlStyler 2 KB
Versions
The database has no other skills named formatting-wpf-csharp-code.
Database snapshot: 13.11.2026 · package version fb10e89f72d8 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 96dotnet-wpf
.NET WPF component and application patterns Triggers on: **/*.xaml, **/*.cs - 84make-wpf-behavior
Generates WPF Behavior<T> classes using Microsoft.Xaml.Behaviors.Wpf. Use when adding reusable interaction logic to controls, creating drag behaviors, or scaffolding a new Behavior class. Usage: /wpf-dev-pack:make-wpf-behavior <BehaviorName> - 84make-wpf-converter
Generates WPF IValueConverter or IMultiValueConverter classes with MarkupExtension pattern. Use when creating a new value converter, scaffolding a MultiValueConverter, or adding a converter with direct XAML usage. Usage: /wpf-dev-pack:make-wpf-converter <ConverterName> [multi] - 100dotnet-modern-csharp-editorconfig
Drop-in opinionated .editorconfig for modern C# (C# 14 on .NET 10, also works with C# 10–13) that enforces concise, readable code leveraging the latest language features. Use when setting up code-style rules, naming conventions, formatting, and preview analyzer severities for a… - 86wpf
WPF桌面应用开发专家助手。当用户需要进行Windows桌面应用开发、XAML界面设计、MVVM架构或WPF数据绑定时调用。 - 100editorconfig
Generates a minimal .editorconfig with sensible defaults for a repository. Use when starting work in a new repository, when a project has no .editorconfig, or when the user asks to add or standardise editor and formatting settings.