Skip to content

Refresh PhotoEditor C# sample to modern Windows App SDK conventions - #654

Open
Niels Laute (niels9001) wants to merge 2 commits into
mainfrom
user/niels9001/refresh-photoeditor-cs-winui
Open

Refresh PhotoEditor C# sample to modern Windows App SDK conventions#654
Niels Laute (niels9001) wants to merge 2 commits into
mainfrom
user/niels9001/refresh-photoeditor-cs-winui

Conversation

@niels9001

Copy link
Copy Markdown
Contributor

Refreshing the PhotoEditor C# sample

The C# (cs-winui) PhotoEditor sample was heavily outdated and carried a lot of Project Reunion-era workarounds. This PR refreshes it to current Windows App SDK conventions by scaffolding a fresh dotnet new winui project and porting the XAML/C# forward.

What changed

Modern window chrome

  • Mica backdrop + TitleBar with the app icon and ExtendsContentIntoTitleBar, replacing the old hand-rolled title bar.
  • Pages no longer set their own background so the system backdrop shows through.

Modern app lifecycle

  • App.MainWindow / DispatcherQueue instead of the static App.Window and CoreWindow-bound patterns.
  • File pickers initialized via the window handle (WindowNative.GetWindowHandle).

Removed Project Reunion-era cruft

  • Dropped every ApiInformation.IsApiContractPresent runtime API-detection check.
  • Removed the contract6/contract7 conditional XAML namespaces and their conditional attributes from the FancySlider control template.
  • Trimmed the misleading "unpackaged applications" comment from app.manifest (this sample is packaged).

Correctness & polish

  • Nullable reference types enabled and annotated across the sample.
  • Robust thumbnail loading: fall back to decoding the image file directly when the packaged install location has no shell-generated thumbnail (fixes a NullReferenceException on launch).
  • csproj modernized to the repo's Central Package Management (no inline package versions), the net8 TFM, and the standard package set.

Validation

  • Builds clean: 0 warnings / 0 errors.
  • Smoke-tested: the collection grid loads all 20 bundled sample photos, connected animation works, and the Win2D effects editor runs without crashing.

Scope is limited to Samples/PhotoEditor/cs-winui and the PhotoEditor README.md. The C++ sample is untouched.

Niels Laute (niels9001) and others added 2 commits July 9, 2026 13:13
…nventions

Rebuilds the C# PhotoEditor sample on a fresh `dotnet new winui` project and
ports the XAML/C# forward, removing Project Reunion-era compatibility cruft.

- Modern window chrome: Mica backdrop + `TitleBar` with app icon and
  `ExtendsContentIntoTitleBar`, replacing the old custom title bar plumbing.
- Modern lifecycle: `App.MainWindow` / `DispatcherQueue` instead of the static
  `App.Window` / `CoreWindow`-bound patterns; pickers initialized via the
  window handle.
- Removed runtime API detection: dropped all
  `ApiInformation.IsApiContractPresent` checks and the `contract6/7`
  conditional XAML namespaces from the FancySlider template.
- Nullable reference types enabled and annotated across the sample.
- Robust thumbnail loading: fall back to decoding the image file directly when
  the packaged install location has no shell-generated thumbnail.
- csproj modernized to Central Package Management (no inline versions), net8
  TFM, and the repo-standard package set.

Builds clean (0 warnings / 0 errors) and smoke-tested: the collection grid
loads the 20 bundled sample photos and the Win2D editor runs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
OS compatibility for this packaged sample is already declared via
TargetDeviceFamily in Package.appxmanifest, so the Win32-style
<compatibility>/<supportedOS> block is unneeded boilerplate.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant