---
phase: 06-global-site-selection
plan: 03
subsystem: ui
tags: [wpf, xaml, toolbar, localization, mvvm, site-picker]

# Dependency graph
requires:
  - phase: 06-global-site-selection/06-02
    provides: OpenGlobalSitePickerCommand, GlobalSitesSelectedLabel, OpenGlobalSitePickerDialog factory property
  - phase: 06-global-site-selection/06-01
    provides: SitePickerDialog (dialog already registered in DI)
provides:
  - Toolbar button "Select Sites" bound to OpenGlobalSitePickerCommand
  - Toolbar TextBlock bound to GlobalSitesSelectedLabel for live site count
  - SitePickerDialog factory wired in MainWindow.xaml.cs
  - 5 EN localization keys for toolbar.selectSites and toolbar.globalSites
  - 5 FR localization keys matching EN keys
  - GlobalSitesSelectedLabel fully localized via TranslationSource
affects:
  - 06-04 (no XAML impact; GlobalSitesChangedMessage broadcast already live from 06-02)

# Tech tracking
tech-stack:
  added: []
  patterns:
    - "TranslationSource.Instance[key] for code-behind label formatting (same as PermissionsViewModel)"
    - "Func<TenantProfile, SitePickerDialog> DI factory resolved in MainWindow.xaml.cs code-behind"
    - "XAML binding Path=[toolbar.selectSites] for localized button content and tooltip"

key-files:
  created: []
  modified:
    - SharepointToolbox/Localization/Strings.resx
    - SharepointToolbox/Localization/Strings.fr.resx
    - SharepointToolbox/ViewModels/MainWindowViewModel.cs
    - SharepointToolbox/MainWindow.xaml
    - SharepointToolbox/MainWindow.xaml.cs

key-decisions:
  - "Added using SharepointToolbox.Core.Models to MainWindow.xaml.cs for TenantProfile — required by SitePickerDialog factory lambda"
  - "TextBlock foreground set to Gray to visually distinguish label from action buttons"
  - "Disabled tooltip (toolbar.selectSites.tooltipDisabled) added to resources for future use; not wired in XAML because WPF Button does not show ToolTip when IsEnabled=false without a style trigger"

patterns-established:
  - "Global site picker factory pattern in MainWindow.xaml.cs mirrors PermissionsView factory"

requirements-completed:
  - SITE-01

# Metrics
duration: 2min
completed: 2026-04-07
---

# Phase 06 Plan 03: Toolbar UI, Localization, and Dialog Factory Wiring Summary

**Select Sites button and count label added to MainWindow toolbar; 5 EN + 5 FR localization keys added; GlobalSitesSelectedLabel localized via TranslationSource; SitePickerDialog factory wired in MainWindow code-behind**

## Performance

- **Duration:** ~2 min
- **Started:** 2026-04-07T08:06:13Z
- **Completed:** 2026-04-07T08:07:51Z
- **Tasks:** 3
- **Files modified:** 5

## Accomplishments

- Added 5 EN and 5 FR localization keys for the global site picker toolbar controls — button label, tooltip, disabled tooltip, count format, and empty state
- Updated `GlobalSitesSelectedLabel` in `MainWindowViewModel` from hardcoded English strings to `TranslationSource.Instance` lookups — label now switches language with the app
- Added `<Separator />`, `<Button>` (bound to `OpenGlobalSitePickerCommand`), and `<TextBlock>` (bound to `GlobalSitesSelectedLabel`) to the ToolBar in `MainWindow.xaml`
- Wired `viewModel.OpenGlobalSitePickerDialog` factory in `MainWindow.xaml.cs` — clicking "Select Sites" now opens `SitePickerDialog` via DI, identical to the `PermissionsView` pattern

## Task Commits

Each task was committed atomically:

1. **Task 1: Add EN/FR localization keys** - `185642f` (feat)
2. **Task 2: Localize GlobalSitesSelectedLabel** - `467a940` (feat)
3. **Task 3: Toolbar controls + dialog factory wiring** - `45eb531` (feat)

## Files Created/Modified

- `SharepointToolbox/Localization/Strings.resx` - Added 5 toolbar.selectSites / toolbar.globalSites keys (EN)
- `SharepointToolbox/Localization/Strings.fr.resx` - Added 5 matching FR translations
- `SharepointToolbox/ViewModels/MainWindowViewModel.cs` - GlobalSitesSelectedLabel now uses TranslationSource.Instance
- `SharepointToolbox/MainWindow.xaml` - Added Separator + Select Sites Button + count TextBlock to ToolBar
- `SharepointToolbox/MainWindow.xaml.cs` - Added OpenGlobalSitePickerDialog factory wiring + using SharepointToolbox.Core.Models

## Decisions Made

- Added `using SharepointToolbox.Core.Models` to `MainWindow.xaml.cs` to satisfy `TenantProfile` reference in the factory lambda. This is appropriate — code-behind already imports View and ViewModel namespaces.
- `toolbar.selectSites.tooltipDisabled` key added to both resource files for completeness, but not wired in XAML. WPF `Button` does not render `ToolTip` when `IsEnabled=false` without a `Style` trigger; adding that trigger was deferred as it was explicitly called out as optional in the plan.
- `TextBlock` foreground set to `Gray` to provide visual separation from active toolbar buttons.

## Deviations from Plan

None - plan executed exactly as written.

## Issues Encountered

None. Build succeeded with 0 errors after each task. Two pre-existing warnings (`_hasLocalSiteOverride` field never assigned in `PermissionsViewModel` and `DuplicatesViewModel`) are out of scope for this plan.

## User Setup Required

None.

## Next Phase Readiness

- Toolbar is fully wired: button opens dialog, label updates live, both localized
- `OpenGlobalSitePickerDialog` factory is live — clicking "Select Sites" while connected to a tenant will open `SitePickerDialog` and populate `GlobalSelectedSites`
- `WeakReferenceMessenger` broadcasts `GlobalSitesChangedMessage` on every site collection change (from 06-02) — all tab VMs registered in 06-04 will receive updates automatically

---
*Phase: 06-global-site-selection*
*Completed: 2026-04-07*
