---
phase: 04-bulk-operations-and-provisioning
plan: 10
subsystem: ui
tags: [wpf, mvvm, dependency-injection, viewmodel, xaml, community-toolkit]

# Dependency graph
requires:
  - phase: 04-08
    provides: TransferViewModel, TransferView with SitePickerDialog/FolderBrowserDialog wiring
  - phase: 04-09
    provides: BulkMembersViewModel, BulkSitesViewModel, FolderStructureViewModel and all Views
  - phase: 04-02
    provides: TemplateRepository, ICsvValidationService
  - phase: 04-06
    provides: ITemplateService, IFolderStructureService
provides:
  - TemplatesViewModel with capture/apply/rename/delete/refresh
  - TemplatesView with capture checkboxes and apply form
  - All 5 Phase 4 tabs registered in DI and wired in MainWindow
  - EnumBoolConverter, StringToVisibilityConverter, ListToStringConverter in converter library
affects:
  - Phase 5 (any future phase that adds more tabs)

# Tech tracking
tech-stack:
  added: []
  patterns:
    - RenameInputDialog WPF inline dialog (no Microsoft.VisualBasic dependency)
    - GraphClientFactory registered as Singleton (shared MSAL factory)
    - TemplateRepository registered as Singleton (shared template data)
    - Converter classes co-located in IndentConverter.cs (all value converters in one file)

key-files:
  created:
    - SharepointToolbox/ViewModels/Tabs/TemplatesViewModel.cs
    - SharepointToolbox/Views/Tabs/TemplatesView.xaml
    - SharepointToolbox/Views/Tabs/TemplatesView.xaml.cs
  modified:
    - SharepointToolbox/App.xaml.cs
    - SharepointToolbox/MainWindow.xaml
    - SharepointToolbox/MainWindow.xaml.cs
    - SharepointToolbox/Views/Converters/IndentConverter.cs

key-decisions:
  - "TemplatesView uses RenameInputDialog (custom WPF Window) instead of Microsoft.VisualBasic.Interaction.InputBox — avoids additional framework dependency"
  - "EnumBoolConverter, StringToVisibilityConverter, ListToStringConverter added to IndentConverter.cs — all converters in one file, already referenced in App.xaml from prior session"
  - "TemplatesViewModel.CaptureAsync and ApplyAsync are independent AsyncRelayCommands — not routed through RunCommand to allow independent IsRunning management"
  - "Tab order in MainWindow: Permissions, Storage, Search, Duplicates, Transfer, Bulk Members, Bulk Sites, Folder Structure, Templates, Settings"

patterns-established:
  - "Converter co-location: all app-level IValueConverter classes in IndentConverter.cs, registered in App.xaml Application.Resources"
  - "RenameInputDialog pattern: inline WPF Window for simple text input, wired via Func<string, string?> factory on ViewModel"

requirements-completed:
  - TMPL-01
  - TMPL-02
  - TMPL-03
  - TMPL-04

# Metrics
duration: 25min
completed: 2026-04-03
---

# Phase 04 Plan 10: TemplatesViewModel + TemplatesView + DI Registration + MainWindow Wiring Summary

**TemplatesViewModel with capture/apply/rename/delete, all 5 Phase 4 Views registered in DI, MainWindow wired with 10 full tabs replacing 3 FeatureTabBase stubs**

## Performance

- **Duration:** 25 min
- **Started:** 2026-04-03T08:30:00Z
- **Completed:** 2026-04-03T08:55:00Z
- **Tasks:** 2 completed (Task 3 is checkpoint:human-verify)
- **Files modified:** 7

## Accomplishments

- TemplatesViewModel: capture with 5 checkbox options (Libraries, Folders, Permissions, Logo, Settings), apply template to new site, rename/delete/refresh, RenameDialogFactory pattern
- TemplatesView: XAML with capture GroupBox, apply GroupBox, template DataGrid showing Name/Type/Source/CapturedAt
- All Phase 4 DI registrations in App.xaml.cs: TemplateRepository, GraphClientFactory, ICsvValidationService, BulkResultCsvExportService, all 5 service/viewmodel/view pairs
- MainWindow.xaml: replaced 3 FeatureTabBase stubs with 5 named TabItems (TransferTabItem, BulkMembersTabItem, BulkSitesTabItem, FolderStructureTabItem, TemplatesTabItem)
- MainWindow.xaml.cs: wired all 5 new tabs from DI

## Task Commits

Each task was committed atomically:

1. **Prerequisite converters + views (04-08/04-09 catch-up)** - `87dd4bb` (feat) — Added missing converters to IndentConverter.cs
2. **Task 1: TemplatesViewModel + TemplatesView** - `a49bbb9` (feat)
3. **Task 2: DI Registration + MainWindow wiring** - `988bca8` (feat)

**Note:** Task 3 (checkpoint:human-verify) requires manual visual verification by user.

## Files Created/Modified

- `SharepointToolbox/ViewModels/Tabs/TemplatesViewModel.cs` - Templates tab ViewModel with capture/apply/rename/delete commands
- `SharepointToolbox/Views/Tabs/TemplatesView.xaml` - Templates tab XAML with capture checkboxes and template DataGrid
- `SharepointToolbox/Views/Tabs/TemplatesView.xaml.cs` - Code-behind wiring RenameInputDialog factory
- `SharepointToolbox/App.xaml.cs` - Phase 4 DI registrations (7 services, 5 ViewModels, 5 Views)
- `SharepointToolbox/MainWindow.xaml` - 5 new named TabItems replacing 3 stub tabs
- `SharepointToolbox/MainWindow.xaml.cs` - Tab content wiring via GetRequiredService<T>
- `SharepointToolbox/Views/Converters/IndentConverter.cs` - Added EnumBoolConverter, StringToVisibilityConverter, ListToStringConverter

## Decisions Made

- TemplatesView uses `RenameInputDialog` (custom WPF Window) instead of `Microsoft.VisualBasic.Interaction.InputBox` — avoids additional framework dependency, keeps code pure WPF
- All three new converters (EnumBoolConverter, StringToVisibilityConverter, ListToStringConverter) added to existing IndentConverter.cs — consistent with project pattern of co-locating value converters
- TemplatesViewModel.CaptureAsync and ApplyAsync are independent AsyncRelayCommands that manage IsRunning directly — not routed through base RunCommand, allowing capture and apply to have independent lifecycle

## Deviations from Plan

### Auto-fixed Issues

**1. [Rule 3 - Blocking] Missing converter class definitions**
- **Found during:** Task 1 (TemplatesViewModel + TemplatesView)
- **Issue:** App.xaml referenced `EnumBoolConverter`, `StringToVisibilityConverter`, and `ListToStringConverter` (registered by prior session) but the C# class implementations were never committed. Build would fail at runtime XAML parsing.
- **Fix:** Added all three converter classes to `IndentConverter.cs` (established project file for app-level converters)
- **Files modified:** `SharepointToolbox/Views/Converters/IndentConverter.cs`
- **Verification:** Design-time MSBuild compile returns exit 0
- **Committed in:** `87dd4bb` (prerequisite catch-up commit)

---

**Total deviations:** 1 auto-fixed (Rule 3 - blocking missing class definitions)
**Impact on plan:** Essential fix for XAML rendering. No scope creep.

## Issues Encountered

- Prior session (04-08/04-09) had registered EnumBoolConverter and friends in App.xaml but never committed the class implementations — detected and fixed as Rule 3 blocking issue

## Checkpoint: Visual Verification Required

**Task 3 (checkpoint:human-verify) was reached but not completed — requires manual launch and visual inspection.**

To verify:
1. Run: `dotnet run --project SharepointToolbox/SharepointToolbox.csproj`
2. Verify 10 tabs visible: Permissions, Storage, Search, Duplicates, Transfer, Bulk Members, Bulk Sites, Folder Structure, Templates, Settings
3. Click each new tab — verify layout loads without crash
4. On Bulk Members tab: click "Load Example" — DataGrid should populate with sample member data
5. On Bulk Sites tab: click "Load Example" — DataGrid should populate with sample site data
6. On Folder Structure tab: click "Load Example" — DataGrid should populate with folder structure data
7. On Templates tab: verify 5 capture checkboxes (Libraries, Folders, Permission Groups, Logo, Settings)
8. On Transfer tab: verify source/destination sections with Browse buttons

## Next Phase Readiness

- All Phase 4 code complete pending visual verification
- Phase 5 can build on the established 10-tab MainWindow pattern
- TemplateRepository and session infrastructure are singleton-registered and shared

---
*Phase: 04-bulk-operations-and-provisioning*
*Completed: 2026-04-03*
