wpf-mvvm-generator
20
总安装量
10
周安装量
#18294
全站排名
安装命令
npx skills add https://github.com/jeongheonk/c-sharp-custom-marketplace --skill wpf-mvvm-generator
Agent 安装分布
gemini-cli
6
claude-code
6
codex
6
github-copilot
5
cursor
5
Skill 文档
WPF MVVM Generator ì¤í¬
CommunityToolkit.Mvvm source generator를 ì¬ì©íì¬ WPF MVVM ì»´í¬ëí¸ë¥¼ ìì±í©ëë¤.
ì¤ì: 모ë ê²°ê³¼ë ë°ëì íêµì´ë¡ ìì±í©ëë¤. ì½ë ìë³ì, 기ì ì©ì´, í¨í´ ì´ë¦ ë±ì ì문 ê·¸ëë¡ ì ì§íë, ì¤ëª ë¶ë¶ì íêµì´ë¥¼ ì¬ì©í©ëë¤.
ì¸ì
$ARGUMENTS[0]: ìí°í° ì´ë¦ (íì) – ì:User,Product,Order$ARGUMENTS[1]: ìì± ì í (ì í):viewmodel,view,model,all(기본ê°:all)all: Model + ViewModel + View + Code-Behind + Messages + Service Interface 모ë ìì±
ì¤í ë¨ê³
1ë¨ê³: ì¸ì ê²ì¦
$ARGUMENTS[0]ì´ ë¹ì´ìë ê²½ì°:
- ì¬ì©ììê² ìí°í° ì´ë¦ ìì²
- íë¡ì í¸ì 기존 Model 기ë°ì¼ë¡ ì ì
ìí°í° ì´ë¦ ê²ì¦:
- PascalCase ì¬ë¶ íì¸
- C# ìì½ì´ ì¬ì© íì¸
- í¹ì문ì, 공백 í¬í¨ ì ì¬ì©ììê² ì¬ì ë ¥ ìì²
2ë¨ê³: íë¡ì í¸ êµ¬ì¡° íì
기존 í¨í´ì ìë³:
Glob("**/*ViewModel.cs")ë¡ ê¸°ì¡´ ViewModel í¨í´ íì¸- 첫 ë²ì§¸ ë°ê²¬ë íì¼ìì ë¤ìì¤íì´ì¤ ì¶ì¶
/ViewModels,/Views,/Modelsëë í 리 ì¡´ì¬ ì¬ë¶ íì¸- 기존 ë² ì´ì¤ í´ëì¤ ëë ì¸í°íì´ì¤ íì
3ë¨ê³: ì½ë ìì±
$ARGUMENTS[1] 기ì¤ì¼ë¡ ìì±:
ìì± ì»´í¬ëí¸
Model (model)
namespace {Namespace}.Models;
/// <summary>
/// {EntityName} domain model
/// </summary>
public sealed class {EntityName}
{
public required int Id { get; init; }
public required string Name { get; init; }
// 컨í
ì¤í¸ì ë°ë¥¸ ì¶ê° íë¡í¼í°
}
ViewModel (viewmodel)
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
namespace {Namespace}.ViewModels;
/// <summary>
/// ViewModel for {EntityName} management
/// </summary>
public partial class {EntityName}ViewModel : ObservableObject
{
private readonly I{EntityName}Service _{entityName}Service;
public {EntityName}ViewModel(I{EntityName}Service {entityName}Service)
{
_{entityName}Service = {entityName}Service;
}
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(HasSelection))]
[NotifyCanExecuteChangedFor(nameof(DeleteCommand))]
private {EntityName}? _selected{EntityName};
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(SaveCommand))]
private bool _isModified;
[ObservableProperty]
private bool _isLoading;
public bool HasSelection => Selected{EntityName} is not null;
[RelayCommand]
private async Task LoadAsync(CancellationToken cancellationToken = default)
{
IsLoading = true;
try
{
// Load logic
}
finally
{
IsLoading = false;
}
}
[RelayCommand(CanExecute = nameof(CanSave))]
private async Task SaveAsync(CancellationToken cancellationToken = default)
{
await _{entityName}Service.SaveAsync(Selected{EntityName}!, cancellationToken);
IsModified = false;
}
private bool CanSave() => IsModified && Selected{EntityName} is not null;
[RelayCommand(CanExecute = nameof(CanDelete))]
private async Task DeleteAsync(CancellationToken cancellationToken = default)
{
if (Selected{EntityName} is null) return;
await _{entityName}Service.DeleteAsync(Selected{EntityName}.Id, cancellationToken);
WeakReferenceMessenger.Default.Send(
new {EntityName}DeletedMessage(Selected{EntityName}));
Selected{EntityName} = null;
}
private bool CanDelete() => Selected{EntityName} is not null;
}
View (view)
<UserControl x:Class="{Namespace}.Views.{EntityName}View"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="{Namespace}.ViewModels"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance vm:{EntityName}ViewModel, IsDesignTimeCreatable=False}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Header -->
<TextBlock Grid.Row="0"
Text="{EntityName} Management"
Style="{StaticResource HeaderStyle}"/>
<!-- Content -->
<ContentControl Grid.Row="1"
Content="{Binding Selected{EntityName}}"
Visibility="{Binding HasSelection, Converter={StaticResource BoolToVisibility}}"/>
<!-- Actions -->
<StackPanel Grid.Row="2"
Orientation="Horizontal"
HorizontalAlignment="Right">
<Button Content="Save"
Command="{Binding SaveCommand}"/>
<Button Content="Delete"
Command="{Binding DeleteCommand}"/>
</StackPanel>
<!-- Loading Overlay -->
<Border Grid.RowSpan="3"
Background="#80000000"
Visibility="{Binding IsLoading, Converter={StaticResource BoolToVisibility}}">
<ProgressBar IsIndeterminate="True" Width="200"/>
</Border>
</Grid>
</UserControl>
Code-Behind (ìµìí)
namespace {Namespace}.Views;
public partial class {EntityName}View : UserControl
{
public {EntityName}View()
{
InitializeComponent();
}
}
Message Types
namespace {Namespace}.Messages;
public sealed record {EntityName}DeletedMessage({EntityName} Deleted{EntityName});
public sealed record {EntityName}SelectedMessage({EntityName} Selected{EntityName});
public sealed record {EntityName}SavedMessage({EntityName} Saved{EntityName});
Service Interface
namespace {Namespace}.Services;
public interface I{EntityName}Service
{
Task<IReadOnlyList<{EntityName}>> GetAllAsync(CancellationToken cancellationToken = default);
Task<{EntityName}?> GetByIdAsync(int id, CancellationToken cancellationToken = default);
Task SaveAsync({EntityName} entity, CancellationToken cancellationToken = default);
Task DeleteAsync(int id, CancellationToken cancellationToken = default);
}
ì¶ë ¥ íì
모ë ë´ì©ì íêµì´ë¡ ìì±í©ëë¤. ì½ë ìë³ìì 기ì ì©ì´ë ì문ì ì ì§í©ëë¤.
# MVVM ìì± ê²°ê³¼
## ìí°í°: {EntityName}
### ìì±ë íì¼
| íì¼ | ê²½ë¡ | ìí |
|------|------|------|
| Model | /Models/{EntityName}.cs | ìì±ë¨ |
| ViewModel | /ViewModels/{EntityName}ViewModel.cs | ìì±ë¨ |
| View | /Views/{EntityName}View.xaml | ìì±ë¨ |
| Code-Behind | /Views/{EntityName}View.xaml.cs | ìì±ë¨ |
| Messages | /Messages/{EntityName}Messages.cs | ìì±ë¨ |
| Service Interface | /Services/I{EntityName}Service.cs | ìì±ë¨ |
### ë¤ì ë¨ê³
1. `I{EntityName}Service` 구í
2. DI 컨í
ì´ëì ë±ë¡
3. View ë´ë¹ê²ì´ì
ì¶ê°
4. íì ì ëìì¸ íì ë°ì´í° ìì±
ìë¬ ì²ë¦¬
| ìí© | ì²ë¦¬ |
|---|---|
| ìí°í° ì´ë¦ 미ì ë ¥ | ì¬ì©ììê² ìì², 기존 Model ê¸°ë° ì ì |
| ì í¨íì§ ìì ì´ë¦ (í¹ì문ì, ìì½ì´) | ì¬ì©ììê² ì¬ì ë ¥ ìì² |
| ViewModels/Views/Models ëë í 리 ìì | ëë í 리 ìë ìì± í ì§í |
| ëì¼ ì´ë¦ íì¼ ì¡´ì¬ | ì¬ì©ììê² ë®ì´ì°ê¸° íì¸ |
ê°ì´ëë¼ì¸
- CommunityToolkit.Mvvm source generator를 ì¬ì©í©ëë¤
- 기존 íë¡ì í¸ ëª ëª ê·ì¹ì ë°ë¦ ëë¤
- ìµìíì Code-Behindì ìì±í©ëë¤ (UI ë¡ì§ë§)
- ì ì í XML 문ìí를 í¬í¨í©ëë¤
- ë¹ë기 ìì ì CancellationTokenì ì§ìí©ëë¤
- ViewModel ê° íµì ì WeakReferenceMessenger를 ì¬ì©í©ëë¤