Generate view model commands with [RelayCommand] #182

Closed
opened 2026-10-26 17:56:30 -05:00 by ethan-hann · 1 comment
Owner

.agents/coding-standards/app-mvvm-view-models.md says a command a view model owns is a [RelayCommand] method, with a named CanExecute property for its gate. new RelayCommand(...) is only for a command one object builds and hands to another, such as the remove command on each chip.

These view models build their own commands by hand, in constructors or field ??= new RelayCommand(...) properties, many with the gate in a lambda: GamesScreenViewModel, NewProfileWizardViewModel, ProfileRowViewModel, StorageSectionViewModel, TourViewModel, StartupViewModel, ShellViewModel, HelpSectionViewModel, HistoryScreenViewModel, HowItWorksViewModel, JobDetailsViewModel, JobStatusViewModel, SettingsScreenViewModel, ClearAllDataSectionViewModel, ContextualHelpViewModel, FreeUpSpaceViewModel, ActivityScreenViewModel.

Keep the hand-written ones that are handed off (for example the commands ShellViewModel passes into FirstRunViewModel). Find them with:

grep -rnE "Command\s*(=|\?\?=)\s*new (Async)?RelayCommand|=> field \?\?= new (Async)?RelayCommand" --include=*.cs src/Savepoint.App
`.agents/coding-standards/app-mvvm-view-models.md` says a command a view model owns is a `[RelayCommand]` method, with a named `CanExecute` property for its gate. `new RelayCommand(...)` is only for a command one object builds and hands to another, such as the remove command on each chip. These view models build their own commands by hand, in constructors or `field ??= new RelayCommand(...)` properties, many with the gate in a lambda: `GamesScreenViewModel`, `NewProfileWizardViewModel`, `ProfileRowViewModel`, `StorageSectionViewModel`, `TourViewModel`, `StartupViewModel`, `ShellViewModel`, `HelpSectionViewModel`, `HistoryScreenViewModel`, `HowItWorksViewModel`, `JobDetailsViewModel`, `JobStatusViewModel`, `SettingsScreenViewModel`, `ClearAllDataSectionViewModel`, `ContextualHelpViewModel`, `FreeUpSpaceViewModel`, `ActivityScreenViewModel`. Keep the hand-written ones that are handed off (for example the commands `ShellViewModel` passes into `FirstRunViewModel`). Find them with: grep -rnE "Command\s*(=|\?\?=)\s*new (Async)?RelayCommand|=> field \?\?= new (Async)?RelayCommand" --include=*.cs src/Savepoint.App
ethan-hann added this to the Code Cleanup milestone 2026-10-26 17:56:30 -05:00
Author
Owner

Shipped in 0.9.17 (PR 227).

Shipped in [0.9.17](https://git.tortal.tech/ethan-hann/SavePoint/releases/tag/v0.9.17) (PR 227).
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ethan-hann/SavePoint#182
No description provided.