---
phase: 07-user-access-audit
plan: 05
subsystem: view
tags: [view, xaml, wpf, people-picker, datagrid, color-coding, grouping, filtering, summary-banner]

requires:
  - phase: 07-04
    provides: [UserAccessAuditViewModel with all observable properties and commands]
  - phase: 07-01
    provides: [UserAccessEntry, AccessType enum]
provides:
  - UserAccessAuditView XAML + code-behind wired to UserAccessAuditViewModel
affects: [07-07, 07-08]

tech-stack:
  added: []
  patterns: [PermissionsView two-panel layout, DataTrigger row color-coding, GroupStyle Expander, code-behind CollectionChanged wiring for autocomplete visibility]

key-files:
  created:
    - SharepointToolbox/Views/Tabs/UserAccessAuditView.xaml
    - SharepointToolbox/Views/Tabs/UserAccessAuditView.xaml.cs
  modified: []

key-decisions:
  - "Autocomplete ListBox visibility managed from code-behind via SearchResults.CollectionChanged rather than DataTrigger — WPF DataTrigger cannot compare to non-zero Count without a converter"
  - "Single ListBox for autocomplete (not Popup) following plan's recommended simpler alternative — avoids Popup placement complexity"
  - "Dialog factory wiring deferred to plan 07-07 (MainWindow.xaml.cs) as specified; code-behind is minimal"

metrics:
  duration_minutes: 4
  completed_date: "2026-04-07"
  tasks_completed: 2
  files_created: 2
  files_modified: 0
---

# Phase 7 Plan 05: UserAccessAuditView Summary

**XAML view for User Access Audit tab with people-picker autocomplete (ListBox shown via CollectionChanged), removable user pills, site picker, scan options, 3-card summary banner, filter TextBox, group-by ToggleButton, color-coded DataGrid with access type icons, Guest badge for external users, warning icon for high-privilege rows, and GroupStyle Expander headers — zero-error build.**

## Performance

- **Duration:** ~4 min
- **Started:** 2026-04-07T10:46:02Z
- **Completed:** 2026-04-07T10:49:45Z
- **Tasks:** 2
- **Files modified:** 2

## Accomplishments

- `UserAccessAuditView.xaml` (~415 lines) — two-panel layout following PermissionsView pattern with all required UI elements bound to UserAccessAuditViewModel properties
- Left panel: People picker GroupBox (search TextBox + autocomplete ListBox + removable pill ItemsControl + SelectedUsersLabel), Site GroupBox (site picker button + SitesSelectedLabel), Scan Options GroupBox (3 checkboxes), action buttons (Run/Cancel + CSV/HTML export in 2x2 grid)
- Right panel: Summary banner (3 stat cards for TotalAccessCount, SitesCount, HighPrivilegeCount with distinct color schemes), filter TextBox + group-by ToggleButton toolbar, DataGrid with ResultsView ICollectionView binding
- DataGrid row style: DataTriggers for AccessType (Direct=blue #EBF5FB, Group=green #EAFAF1, Inherited=gray #F4F6F6) + FontWeight=Bold for IsHighPrivilege
- DataGrid columns: User (with orange Guest badge for IsExternalUser), Site, Object, Permission Level (with warning triangle icon for IsHighPrivilege), Access Type (with Segoe UI Symbol icon + colored label), Granted Through
- GroupStyle with Expander template showing group name + ItemCount
- Status bar with ProgressBar (0-100) + StatusMessage spanning both columns
- `UserAccessAuditView.xaml.cs` — minimal code-behind with DI constructor, CollectionChanged wiring for autocomplete visibility, and OnSearchResultClicked handler

## Task Commits

1. **Task 1: Create UserAccessAuditView XAML layout** - `bb9ba9d` (feat)
2. **Task 2: Create UserAccessAuditView code-behind** - `975762d` (feat)

## Files Created/Modified

- `SharepointToolbox/Views/Tabs/UserAccessAuditView.xaml` — Full audit tab XAML with two-panel layout, people picker, summary banner, color-coded DataGrid
- `SharepointToolbox/Views/Tabs/UserAccessAuditView.xaml.cs` — Code-behind with ViewModel injection, autocomplete visibility wiring, click handler

## Decisions Made

1. **Autocomplete ListBox visibility via code-behind** — WPF DataTriggers can only match exact values (e.g., `True`/`False`), not "Count > 0". Rather than adding a converter or a `HasSearchResults` bool property to the ViewModel, the code-behind subscribes to `SearchResults.CollectionChanged` and sets `SearchResultsList.Visibility` directly. This keeps the ViewModel clean and avoids adding converter infrastructure.

2. **Simple ListBox instead of Popup** — The plan listed a Popup as the primary approach and a "simpler alternative" of a ListBox directly below the TextBox. The ListBox approach was chosen to avoid Popup placement issues (the Popup can overlap other controls or escape the panel bounds). The visual result is equivalent.

3. **Dialog factory deferred to 07-07** — As specified in the plan, the SitePickerDialog factory is not wired in the code-behind. It will be set from MainWindow.xaml.cs in plan 07-07, following the same pattern used by PermissionsView.

## Deviations from Plan

### Auto-fixed Issues

**1. [Rule 2 - Missing functionality] Autocomplete visibility from code-behind**
- **Found during:** Task 2
- **Issue:** WPF DataTrigger cannot bind to `SearchResults.Count > 0` without a value converter. The initial XAML used a `CountToVisibilityConverter` reference that did not exist, causing a build error.
- **Fix:** Removed converter reference, set initial `Visibility="Collapsed"` on ListBox, wired `SearchResults.CollectionChanged` in code-behind to toggle visibility based on Count.
- **Files modified:** `UserAccessAuditView.xaml`, `UserAccessAuditView.xaml.cs`
- **Commit:** Included in `975762d`

## Issues Encountered

Build error MC2000 on first attempt — `CountToVisibilityConverter` reference was leftover from an intermediate version of the XAML. Fixed by switching to code-behind wiring.

## User Setup Required

None — no external service configuration required.

## Next Phase Readiness

- UserAccessAuditView ready to be registered in DI and added as a tab in MainWindow (plan 07-07)
- All ViewModel bindings are wired: people picker, site picker, scan options, run/cancel/export, DataGrid with grouping/filtering, summary banner
- Dialog factory (`OpenSitePickerDialog`) left as `null` — to be wired in 07-07 from MainWindow.xaml.cs

---
*Phase: 07-user-access-audit*
*Completed: 2026-04-07*
