본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)40k · #7304

mvvm-toolkit

하는 일

이 도구는 프로그래머가 애플리케이션 코드를 더 효율적으로 작성하도록 돕습니다. 사용자 인터페이스와 명령을 만드는 반복적인 부분을 자동화해, 개발을 더 빠르고 실수가 적게 만듭니다.

사용하는 경우

  • ✓애플리케이션의 표시 로직(ViewModel)을 만들거나 검토할 때.
  • ✓사용자가 수행할 수 있는 버튼이나 동작을 정의해야 할 때.
  • ✓사용자가 양식에 입력한 정보를 검증해야 할 때.

스킬 링크

https://github.com/github/awesome-copilot/blob/main/skills/mvvm-toolkit/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/github/awesome-copilot/blob/main/skills/mvvm-toolkit/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이름 칸이 비어 있지 않을 때만 동작하고 사용자 데이터를 저장하는 버튼은 어떻게 만들 수 있나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 도구는 코드 생성기를 사용합니다. 프로그래머가 추가한 간단한 주석(어노테이션)을 바탕으로 추가 코드를 자동으로 만듭니다. 덕분에 프로그래머가 반복적인 코드를 직접 많이 쓸 필요가 없습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

CommunityToolkit.Mvvm (core)

Use this skill when authoring or reviewing ViewModels, properties, commands, or validation in apps that use CommunityToolkit.Mvvm 8.x.

Companion skills. Load mvvm-toolkit-messenger for IMessenger pub/sub patterns. Load mvvm-toolkit-di for Microsoft.Extensions.DependencyInjection integration.

Quick recap. [ObservableProperty] on private fields in partial classes; [RelayCommand] on instance methods; inherit from ObservableObject (or ObservableValidator for input forms, ObservableRecipient when using IMessenger).


Package & setup

<ItemGroup>
  <PackageReference Include="CommunityToolkit.Mvvm" Version="8.*" />
</ItemGroup>

Targets: netstandard2.0, netstandard2.1, net6.0+. Works on .NET, .NET Framework, Mono. Source generators ship in the same NuGet — no extra analyzer reference required.

Namespaces:

using CommunityToolkit.Mvvm.ComponentModel;   // ObservableObject, [ObservableProperty]
using CommunityToolkit.Mvvm.Input;             // [RelayCommand], RelayCommand, AsyncRelayCommand

Universal rule. Every type that uses [ObservableProperty] or [RelayCommand] — and every enclosing type, if nested — must be declared partial. Without it, the generators emit MVVMTK0008 / MVVMTK0042.


Source generators cheat sheet

Attribute Applied to Generates
[ObservableProperty] private field Public INotifyPropertyChanged property + OnXxxChanging/OnXxxChanged partial-method hooks
[NotifyPropertyChangedFor(nameof(Other))] observable field Also raises PropertyChanged for the listed property
[NotifyCanExecuteChangedFor(nameof(MyCommand))] observable field Calls MyCommand.NotifyCanExecuteChanged() on change
[NotifyDataErrorInfo] observable field on ObservableValidator Calls ValidateProperty(value) from the setter
[NotifyPropertyChangedRecipients] observable field on ObservableRecipient Broadcast(old, new) after the change
[RelayCommand] instance method Lazy RelayCommand / AsyncRelayCommand exposed as IRelayCommand / IAsyncRelayCommand
[RelayCommand(CanExecute = nameof(CanX))] instance method Wires CanExecute to a method or property
[RelayCommand(IncludeCancelCommand = true)] async method with CancellationToken Also generates XxxCancelCommand
[RelayCommand(AllowConcurrentExecutions = true)] async method Allows queued/parallel invocations (default disables while running)
[RelayCommand(FlowExceptionsToTaskScheduler = true)] async method Surfaces exceptions via ExecutionTask instead of awaiting and rethrowing
[property: SomeAttr] observable field or [RelayCommand] method Forwards SomeAttr onto the generated property (e.g., [JsonIgnore])

Naming. Field name / _name / m_name → Name. Method LoadAsync → LoadCommand (the Async suffix is stripped; a leading On is also stripped).

See references/source-generators.md for the full attribute reference with generated-code samples.


ViewModel patterns

Simple observable property

public partial class ContactViewModel : ObservableObject
{
    [ObservableProperty]
    private string? name;
}

Hooks: OnXxxChanging / OnXxxChanged

[ObservableProperty]
private string? name;

partial void OnNameChanged(string? value) =>
    Logger.LogInformation("Name changed to {Name}", value);

Both single-arg (value) and two-arg (oldValue, newValue) overloads are available. Implement only the ones you need; unimplemented hooks are elided by the compiler (zero runtime cost).

Dependent properties + dependent commands

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(FullName))]
[NotifyCanExecuteChangedFor(nameof(SaveCommand))]
private string? firstName;

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(FullName))]
[NotifyCanExecuteChangedFor(nameof(SaveCommand))]
private string? lastName;

public string FullName => $"{FirstName} {LastName}".Trim();

Wrapping a non-observable model

public sealed class ObservableUser(User user) : ObservableObject
{
    public string Name
    {
        get => user.Name;
        set => SetProperty(user.Name, value, user, (u, n) => u.Name = n);
    }
}

…

자주 묻는 질문

따로 설치해야 할 것이 있나요?

아니요. 주요 도구는 CommunityToolkit.Mvvm 패키지 설치에 함께 들어 있습니다.

'코드 생성기'는 무엇인가요?

지시한 내용을 바탕으로 코드를 자동으로 써 주는 도구입니다. 반복적인 코드를 직접 쓰는 일을 줄여 줍니다.

언제 ObservableObject 대신 ObservableValidator를 써야 하나요?

애플리케이션이 양식에 사용자가 입력한 정보를 검증해야 할 때, 예를 들어 필수 항목을 채웠는지 확인해야 할 때 ObservableValidator를 사용합니다.

상세 정보

작성자의 원본 설명

CommunityToolkit.Mvvm (the MVVM Toolkit) core: source generators ([ObservableProperty], [RelayCommand], [NotifyPropertyChangedFor], [NotifyCanExecuteChangedFor], [NotifyDataErrorInfo]), base classes (ObservableObject / ObservableValidator / ObservableRecipient), commands (RelayCommand / AsyncRelayCommand), and validation. Companion skills: mvvm-toolkit-messenger for pub/sub, mvvm-toolkit-di for Mi

repo: github/awesome-copilot

인기도

GitHub 스타
40k
순위
#7304
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬