Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

make-wpf-project

/make-wpf-project

Tworzy strukturę projektu WPF z MVVM i DI w wariantach minimalnym, pełnym lub Prism, dla nowej aplikacji.

Licencja
MIT
Ostatnia zmiana repozytorium
21.07.2026

Ocena i bezpieczeństwo

84/ 100Klasa: dobry
Format9 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
2
Skrypty
0
Komentarze HTML
4
Adresy URL w SKILL.md
6
Przestarzałość

Brak sygnałów. Repozytorium zmienione 21.07.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co sprawdzić przed instalacją
  • SKILL.md zawiera komentarze HTML (4). Nie widać ich w podglądzie Markdown, a model je czyta.

Co robi i kiedy

Tworzy strukturę projektu WPF z MVVM i DI w wariantach minimalnym, pełnym lub Prism, dla nowej aplikacji.

Argumenty

/make-wpf-project [ProjectName]
Oryginalny opis (EN)

Scaffolds a complete WPF project structure with MVVM, DI, and best practices. Use when starting a new WPF application, creating a WPF solution from scratch, or setting up project structure with CommunityToolkit.Mvvm or Prism. Usage: /wpf-dev-pack:make-wpf-project <ProjectName> [--minimal|--full|--prism]

Jak działa

  1. Usage
  2. Project Structures
  3. Composition Style (CommunityToolkit.Mvvm)
  4. Generated Files
  5. CLI Commands
  6. Prism vs CommunityToolkit.Mvvm
  7. Next Steps
  8. Related knowledge topics (via WpfDevPackMcp)
Sekcje z nagłówków SKILL.md, w oryginale · 359 linii, 1 092 słów
Podgląd SKILL.md
---
description: "Scaffolds a complete WPF project structure with MVVM, DI, and best practices. Use when starting a new WPF application, creating a WPF solution from scratch, or setting up project structure with CommunityToolkit.Mvvm or Prism. Usage: /wpf-dev-pack:make-wpf-project <ProjectName> [--minimal|--full|--prism]"
argument-hint: [ProjectName]
---

# WPF Project Scaffolder

**If `$0` is empty, use the AskUserQuestion tool to ask: "Enter the WPF project name (e.g., MyApp, Dashboard)". Do NOT proceed until a valid name is provided. Use the response as the ProjectName for all subsequent steps.**

Scaffold a WPF project named `$0` with MVVM, DI, and best practices.

## Usage

```bash
# Default project (recommended) - CommunityToolkit.Mvvm + GenericHost
/wpf-dev-pack:make-wpf-project $0

# Minimal structure
/wpf-dev-pack:make-wpf-project $0 --minimal

# Full structure (all layers separated)
/wpf-dev-pack:make-wpf-project $0 --full

# Prism framework (module-based architecture)
/wpf-dev-pack:make-wpf-project $0 --prism
```

### Framework Options

| Option | Framework | Features |
|--------|-----------|----------|
| (default) | CommunityToolkit.Mvvm | Lightweight, Source Generator, GenericHost DI |
| `--prism` | Prism.DryIoc | Region Navigation, Module, Dialog Service |

> **Prism details**: See [PRISM.md](PRISM.md) for complete Prism project structure and examples.

> **Project naming (consistency contract)**: the WPF application project is
> suffixed **`.WpfApp`**. The `make-wpf-viewmodel` and `make-wpf-service`
> generators locate the app project by this suffix to place Views and register
> DI. Keep `.WpfApp` so the whole `make-wpf-*` family wires into one solution.

---

## Project Structures

### Default Structure

```
$0/
├── $0.sln
├── $0.WpfApp/                  # WPF Application (entry point + Views)
│   ├── App.xaml                # merges Mappings.xaml
│   ├── App.xaml.cs             # GenericHost + DI
│   ├── MainWindow.xaml         # shell: ContentControl nav host
│   ├── MainWindow.xaml.cs
│   ├── GlobalUsings.cs
│   ├── Mappings.xaml           # ViewModel→View DataTemplate map
│   ├── Views/
│   ├── Converters/
│   └── $0.WpfApp.csproj
├── $0.ViewModels/             # ViewModel (pure C#, no System.Windows)
│   ├── MainViewModel.cs
│   ├── GlobalUsings.cs
│   └── $0.ViewModels.csproj
└── $0.Core/                   # Business logic + service interfaces
    ├── Models/
    ├── Services/
    └── $0.Core.csproj
```

### Minimal Structure

```
$0/
├── $0.sln
└── $0/
    ├── App.xaml
    ├── App.xaml.cs
    ├── MainWindow.xaml
    ├── MainWindow.xaml.cs
    ├── Mappings.xaml
    ├── ViewModels/
    │   └── MainViewModel.cs
    ├── Views/
    ├── Models/
    ├── Services/
    └── $0.csproj
```

### Full Structure

```
$0/
├── $0.slnx
├── src/
│   ├── $0.Abstractions/       # Interfaces, abstract classes
│   ├── $0.Core/               # Business logic
│   ├── $0.ViewModels/         # ViewModel
│   ├── $0.WpfServices/        # WPF services (CollectionView etc.)
│   ├── $0.UI/                 # CustomControl library (Themes/Generic.xaml)
│   └── $0.WpfApp/             # WPF Application
└── tests/
    ├── $0.Core.Tests/
    └── $0.ViewModels.Tests/
```

### Prism Structure (`--prism`)

See [PRISM.md](PRISM.md) for complete structure.

---

## Composition Style (CommunityToolkit.Mvvm)

This scaffold establishes **ViewModel First Composition + Stateful ViewModel**
from the start:

- the shell `MainViewModel` exposes `CurrentViewModel`,
- the shell `MainWindow` hosts it in a `ContentControl`, and
- `Mappings.xaml` resolves the View from the ViewModel type via an implicit
  `DataTemplate` (no `x:Key`).

Add screens with `/wpf-dev-pack:make-wpf-viewmodel <Name> --with-view`, which
appends one `DataTemplate` to `Mappings.xaml` and registers DI.
`ViewModelLocator`, code-behind `DataContext = new VM()`, and inline XAML
`DataContext` are prohibited (see `prohibitions.md`).

---

## Generated Files

### $0.WpfApp.csproj

```xml
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net10.0-windows</TargetFramework>
    <!-- Assembly is $0.WpfApp but root namespace is $0, so View/ViewModel
         namespaces ($0.Views / $0.ViewModels) line up across projects. -->
    <RootNamespace>$0</RootNamespace>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.*" />
    <PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.*" />
  </ItemGroup>

  <ItemGroup>
    <!-- Forward slashes: MSBuild accepts them on Windows, and a "\$" sequence
         in this skill body is consumed as an argument escape at invocation. -->
    <ProjectReference Include="../$0.ViewModels/$0.ViewModels.csproj" />
    <ProjectReference Include="../$0.Core/$0.Core.csproj" />
  </ItemGroup>

</Project>
```

### App.xaml (merges Mappings.xaml)

```xml
<Application x:Class="$0.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Mappings.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
```

> No `StartupUri` — the host resolves and shows `MainWindow` from DI in `OnStartup`.

### App.xaml.cs (with DI)

```csharp
namespace $0;

public partial class App : Application
{
    private readonly IHost _host;

    public App()
    {
        _host = Host.CreateDefaultBuilder()
            .ConfigureServices((context, services) =>
            {
                // Services — add with /wpf-dev-pack:make-wpf-service
                // (that generator adds the registration + the GlobalUsings entry)

                // ViewModels
                services.AddSingleton<MainViewModel>();

                // Windows
                services.AddSingleton<MainWindow>();
            })
            .Build();
    }

    protected override async void OnStartup(StartupEventArgs e)
    {
        await _host.StartAsync();

        var mainWindow = _host.Services.GetRequiredService<MainWindow>();
        mainWindow.DataContext = _host.Services.GetRequiredService<MainViewModel>();
        mainWindow.Show();

        base.OnStartup(e);
    }

    protected override async void OnExit(ExitEventArgs e)
    {
        await _host.StopAsync();
        _host.Dispose();
        base.OnExit(e);
    }
}
```

### MainWindow.xaml (shell — ContentControl nav host)

```xml
<Window x:Class="$0.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="{Binding Title}" Height="600" Width="800">
    <!-- CurrentViewModel is resolved to its View by Mappings.xaml (ViewModel First). -->
    <ContentControl Content="{Binding CurrentViewModel}" />
</Window>
```

```csharp
namespace $0;

public partial class MainWindow : Window
{
    public MainWindow() => InitializeComponent();
}
```

### Mappings.xaml (ViewModel → View)

```xml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:vm="clr-namespace:$0.ViewModels;assembly=$0.ViewModels"
                    xmlns:views="clr-namespace:$0.Views">

    <!-- /wpf-dev-pack:make-wpf-viewmodel appends one entry per screen, e.g.:
    <DataTemplate DataType="{x:Type vm:HomeViewModel}">
        <views:HomeView />
    </DataTemplate>
    -->

</ResourceDictionary>
```

### MainViewModel.cs (shell)

```csharp
namespace $0.ViewModels;

public sealed partial class MainViewModel : ObservableObject
{
    [ObservableProperty] private string _title = "$0";

    // ViewModel First: assign a screen ViewModel to CurrentViewModel and
    // Mappings.xaml resolves the matching View into the shell ContentControl.
    // Set this once you add a screen with /wpf-dev-pack:make-wpf-viewmodel.
    [ObservableProperty] private object? _currentViewModel;
}
```

### GlobalUsings.cs (WpfApp)

```csharp
global using System;
global using System.Collections.Generic;
global using System.Collections.ObjectModel;
global using System.Linq;
global using System.Threading.Tasks;
global using System.Windows;
global using CommunityToolkit.Mvvm.ComponentModel;
global using CommunityToolkit.Mvvm.Input;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
global using $0.ViewModels;
```

> When other generators need more global usings (e.g. `make-wpf-converter` needs
> `System.Windows.Data` / `System.Windows.Markup`), **append to this existing
> `GlobalUsings.cs`** — do not create a second `GlobalUsings.cs` in the same
> project (duplicate `global using` directives fail to compile).

---

## CLI Commands

```bash
# Create solution
dotnet new sln -n $0

# Create projects (note the .WpfApp suffix on the application project)
dotnet new wpf -n $0.WpfApp
dotnet new classlib -n $0.ViewModels
dotnet new classlib -n $0.Core

# Add projects to solution
dotnet sln add $0.WpfApp/$0.WpfApp.csproj
dotnet sln add $0.ViewModels/$0.ViewModels.csproj
dotnet sln add $0.Core/$0.Core.csproj

# Add project references
dotnet add $0.WpfApp reference $0.ViewModels
dotnet add $0.WpfApp reference $0.Core
dotnet add $0.ViewModels reference $0.Core

# Add packages
dotnet add $0.WpfApp package CommunityToolkit.Mvvm
dotnet add $0.WpfApp package Microsoft.Extensions.Hosting
dotnet add $0.ViewModels package CommunityToolkit.Mvvm
```

---

## Prism vs CommunityToolkit.Mvvm

| Feature | CommunityToolkit.Mvvm | Prism |
|---------|----------------------|-------|
| Base Class | `ObservableObject` | `BindableBase` |
| Command | `RelayCommand` (Source Gen) | `DelegateCommand` |
| DI Container | GenericHost (any) | DryIoc, Unity, etc. |
| Navigation | `CurrentViewModel` + Mappings.xaml | `IRegionManager` |
| Dialog | Manual implementation | `IDialogService` |
| Module | Not supported | `IModule` |
| Best for | Small-Medium apps | Medium-Large apps |

---

## Next Steps

1. **Add a screen (View + ViewModel)**: `/wpf-dev-pack:make-wpf-viewmodel <Name> --with-view`
2. **Add a CustomControl**: `/wpf-dev-pack:make-wpf-custom-control <Name>`
3. **Add a Converter**: `/wpf-dev-pack:make-wpf-converter <Name>`
4. **Add a Service**: `/wpf-dev-pack:make-wpf-service <Name>`

---

## Related knowledge topics (via WpfDevPackMcp)

Fetch with `WpfDevPackMcp get_wpf_topic`:

- `structuring-wpf-projects` — project / solution structure
- `configuring-dependency-injection` — DI setup
- `implementing-communitytoolkit-mvvm` — MVVM pattern
Pliki w paczce (2)
  • PRISM.md 10 KB
  • SKILL.md 11 KB

Wersje

W bazie nie ma innych skilli o nazwie make-wpf-project.

Migawka bazy z 13.11.2026 · wersja paczki 20dfcfa4e5d9 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 86wpf
    Pomaga przy aplikacjach desktopowych WPF: projektowaniu interfejsów XAML, architekturze MVVM i wiązaniu danych.
  • 84make-wpf-service
    Generuje w WPF interfejs serwisu, jego implementację i rejestrację w DI, opcjonalnie bez interfejsu.
  • 84developing-wpf-customcontrols
    Tworzy kontrolki WPF z TemplatePart, TemplateVisualState i VisualStateManager, według modelu części i stanów.
  • 100winui-wpf-migration
    Migruje aplikację WPF do WinUI 3: przestrzenie nazw, mapowanie kontrolek, Dispatcher na DispatcherQueue, obrazy, MVVM z CommunityToolkit.Mvvm i ThemeResource.
  • 96dotnet-wpf
    Podaje wzorce komponentów i aplikacji .NET WPF dla plików XAML i C#.
  • 95desktop-wpf
    Pomaga przy aplikacjach desktopowych WPF w .NET i XAML: wiązaniu danych, wzorcu MVVM i kontrolkach niestandardowych.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.