Skip to content

8.7. Editor Mode & DiscriminatorVM

The note editor shows the DiscriminatorVM use case in the example portfolio: one editor surface with several modes, one active at a time.

8.7.1. Scenario Use

All four flagship flavors use DiscriminatorVM to switch the note form between edit and preview modes while keeping the surrounding workflow stable.

8.7.2. Why It Matters

  • mode changes are explicit VM state rather than ad hoc view flags
  • command enablement and derived labels stay attached to the VM layer
  • the host adapter only binds current mode and visible child surface

8.7.3. Where It Lives

  • C#: examples/csharp/avalonia/NotesShowcase/ViewModels/NoteFormVM.cs, member _editorMode
  • Python: examples/python/textual/notes_showcase/src/notes_showcase/viewmodels/note_form_vm.py, member _editor_mode
  • TypeScript: examples/typescript/react/notes-showcase/src/viewmodels/noteFormVM.ts, member #editorMode
  • Swift: examples/swift/notes-showcase/Sources/NotesShowcaseCore/ViewModels/NoteFormVM.swift, member _editorMode

8.7.4. Where To Verify

  • Primitive guide: DiscriminatorVM
  • Parity matrix, which links each flavor README: examples/notes-showcase-parity.md