This skill provides best practices for developing WPF desktop applications using C# and .NET. It is intended for developers looking to apply MVVM architecture and maintain high-quality code.
$ npx skills add https://github.com/jcurbelo/skills --skill wpf-best-practicesThis skill provides comprehensive guidance for developing WPF desktop applications using C# and .NET. It covers modern C# code style including file-scoped namespaces, nullable reference types, and naming conventions aligned with industry standards. The skill teaches MVVM architecture implementation through ViewModelBase and RelayCommand patterns, along with proper project structure for WPF applications and shared libraries. Developers working on Windows desktop applications, system tray apps, XAML UI, and dependency injection setups benefit from practical patterns for async operations, property binding, and command handling. The skill emphasizes code maintainability, type safety, and Windows-specific best practices for professional-grade desktop application development.
Add the skill to your project using the provided installation command.
Implementing MVVM architecture in WPF applications
Applying dependency injection for better modularity
Utilizing async/await patterns in WPF for responsive UI
Integrating Windows desktop features into applications
$ npx skills add https://github.com/jcurbelo/skills --skill wpf-best-practicesgit clone https://github.com/jcurbelo/skillsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Provide best practices for developing a WPF desktop application using C# and .NET. Focus on MVVM architecture, performance optimization, and maintainable code. Use [COMPANY_NAME] as the company name. Consider [TECH_STACK] for any specific dependencies or tools.
# WPF Best Practices for [COMPANY_NAME]
## MVVM Architecture
- **Separation of Concerns**: Ensure View, ViewModel, and Model layers are strictly separated. Use `INotifyPropertyChanged` for data binding in ViewModels.
- **Commands**: Prefer `RelayCommand` or `DelegateCommand` over event handlers for user interactions. Example:
```csharp
public ICommand SaveCommand => new RelayCommand(Save, CanSave);
```
## Performance Optimization
- **Virtualization**: Enable UI virtualization for `ListView` and `DataGrid` to improve rendering performance with large datasets.
- **Data Binding**: Use `Mode=OneWay` or `Mode=OneTime` where possible to reduce unnecessary updates.
## Maintainable Code
- **Dependency Injection**: Use a DI container (e.g., Microsoft.Extensions.DependencyInjection) to manage ViewModel lifetimes.
- **Unit Testing**: Mock ViewModels and test logic without UI dependencies. Example:
```csharp
[Test]
public void SaveCommand_Executes_WhenCanSaveIsTrue()
{
var vm = new CustomerViewModel();
vm.SaveCommand.Execute(null);
Assert.IsTrue(vm.IsSaved);
}
```
## Recommended Tools
- **XAML Styler**: Auto-format XAML for consistency.
- **Live Visual Tree**: Debug UI elements in real-time using Visual Studio.
Apply these practices to enhance [TECH_STACK] integration and scalability.Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan