alpha

Lays down CommunityToolkit.Mvvm coding conventions for ViewModels, commands, messaging, validation and dependency injection across .NET UI frameworks.
description: 'CommunityToolkit.Mvvm (MVVM Toolkit) coding conventions for ViewModels, commands, messaging, validation, and DI across WPF, WinUI 3, .NET MAUI, Uno Platform, and Avalonia.'
applyTo: '**/.cs, **/.xaml, **/*.csproj'
These rules apply whenever a project references CommunityToolkit.Mvvm.
For deep reference and end-to-end examples, load the mvvm-toolkit skill.
CommunityToolkit.Mvvm 8.x (or newer) in .csproj. Do notMicrosoft.Toolkit.Mvvm (7.x) for new projects.LangVersion must support source generators (default in modern SDKs).ObservableObject by default.ObservableValidator only when the ViewModel needsINotifyDataErrorInfo (forms, settings, input validation).ObservableRecipient only when the ViewModel sends or receivesIMessenger messages.INotifyPropertyChanged when one of the toolkit[ObservableObject] or[INotifyPropertyChanged] attribute instead.[ObservableProperty] as partial (and[ObservableProperty] to private fields named name, _name, orm_name — never PascalCase. Let the generator emit the public property.SetProperty(ref field, value) boilerplate when the[ObservableProperty].[NotifyPropertyChangedFor(nameof(Derived))] to raise change[NotifyCanExecuteChangedFor(nameof(XxxCommand))] so commandsCanExecute when their inputs change.OnXxxChanging / OnXxxChanged partial-method hooks forPropertyChanged event.[property: SomeAttribute] to forward an attribute (e.g.,[JsonIgnore], [JsonPropertyName(...)]) onto the generated property.[RelayCommand] on instance methods over manually constructedRelayCommand / AsyncRelayCommand instances.[RelayCommand] methods must return void or Task (or Task<T>).async void — exceptions become unobserved.CancellationToken parameter andIncludeCancelCommand = true to expose a pairedXxxCancelCommand.CanExecute = nameof(...) plus [NotifyCanExecuteChangedFor] on theAllowConcurrentExecutions to false (the default). Only settrue when overlapping invocations are explicitly safe and intended.FlowExceptionsToTaskScheduler = true when the UI binds toExecutionTask to render error states.WeakReferenceMessenger.Default. Only switch toStrongReferenceMessenger.Default when profiling shows the messenger is(recipient, message) lambda form using thestatic modifier — never capture this in the lambda.IRecipient<TMessage> interfaces on ObservableRecipientRegisterAll(this) wires everything automatically whenIsActive = true.IsActive = true on activation (e.g., OnNavigatedTo) andIsActive = false on deactivation (e.g., OnNavigatedFrom).int / string / Guid overloads) to scopeMicrosoft.Extensions.DependencyInjection for service and ViewModelHost.CreateDefaultBuilder()) so configuration, logging, and scopeApp.xaml.cs). Resolve the page's root ViewModel from DI in the pageIoc.Default.GetService<T>() from inside ViewModels, services, or anyAddSingleton<T>() — shell/main-window VMs, settings, file/HTTPIMessenger.AddTransient<T>() — per-page or per-document VMs.AddScoped<T>() — only with explicit IServiceScope usage; rarelyIMessenger onceservices.AddSingleton<IMessenger>(WeakReferenceMessenger.Default))ObservableRecipient(messenger) constructors.ObservableValidator plus [NotifyDataErrorInfo] and DataAnnotation[Required], [Range], [EmailAddress], [MinLength],[MaxLength], [CustomValidation]).ValidateAllProperties() before submitting a form; checkHasErrors and bail out if true.ClearAllErrors() after a successful submit orValidateProperty(value, nameof(Other))OnXxxChanged hook.{x:Bind} (compiled bindings) over{Binding}. Set Mode=OneWay or Mode=TwoWay explicitly — {x:Bind}OneTime.Command="{x:Bind ViewModel.SaveCommand}" directly to theIsRunning, ExecutionTask.Status,ExecutionTask.Exception) to surface progress/errors instead of[ObservableProperty] private string Name; — PascalCase field collidesRaisePropertyChanged(nameof(X)) calls alongside[ObservableProperty] — produces duplicate notifications.Ioc.Default.GetService<T>() from inside a ViewModel constructor —StrongReferenceMessenger without OnDeactivated / UnregisterAll —this in messenger lambdas — closure allocation and(r, m) => r.OnX(m) with static.async void on [RelayCommand] methods — return Task instead.[ObservableProperty] field —true and no change notification fires.ObservableValidator and ObservableRecipient —IMessenger or implement© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com


Y2K flash mirror selfie in a skyline bathroom
Draws a raw late-night mirror selfie in a luxury high-rise bathroom with harsh direct flash, a smudged mirror and a neon skyline, in an early-2000s compact camera look.
image-prompt, gpt-image, selfie, y2k, candid, portrait, woman, night-scene, neon, cityscape, film-grain, film-photography, vertical-format, dramatic-lighting, editorial, luxury, photorealistic, korea, moody, bokeh, fashion, for-content-creators

Toddler sister draws with crayons as baby brother crawls
Generates a Pixar-style 3D animated clip of a toddler girl drawing with crayons, her baby brother ruining the picture, and the two making up with a hug, with no dialogue or text.
video-prompt, seedance, animation, pixar-style, 3d-render, cozy, family-friendly, family, short-film, storytelling, character-consistency, close-up, medium-shot, soft-lighting, vertical-format, negative-prompt, vibrant-colors, for-parents, for-content-creators, camera-movement, short-form-video, whimsical

Woman hugging giant pencil in a cozy room
Makes a warm candid photo of a woman hugging a giant kawaii pencil in a cozy room, with doodle overlays and four miniature chibi replicas of her.
image-prompt, reference-image, face-reference, candid, portrait, woman, cozy, pastel, kawaii, chibi, doodle, miniature, toys, soft-lighting, natural-light, film-grain, vertical-format, dreamy, text-rendering, whimsical, social-media-graphic, photorealistic, nano-banana, for-content-creators, for-photographers, bokeh, warm-tones
Loading reviews…
Loading comments…