Photo Editor

A mini-app for viewing and editing image files, demonstrating XAML layout, data binding, and UI customization features for Windows App SDK apps. Photo Editor shows you how to retrieve photos from the Pictures library, and then edit the selected image with assorted photo effects. In the sample's source code, you'll see a number of common practices such as data binding and asynchronous programming.

Note. This sample is targeted and tested for the Windows App SDK version 1.0 Stable and Visual Studio 2022.

PhotoEditor C++ Sample Application

Photo Editor cpp sample showing the image collection page, editing page, and editing controls

PhotoEditor C# Sample Application

Photo Editor csharp sample showing the image collection page, and editing controls

Features

Photo Editor demonstrates:

  • XAML layout ranging from basics to adaptive and tailored layouts.
  • XAML data binding including the {x:Bind} markup extension.
  • XAML styling and UI customization, including connected animations.
  • Image effects from Windows.UI.Composition.
  • Loading images from the Pictures library using data virtualization to increase performance when there are numerous files.
  • The Microsoft.Graphics.Win2D NuGet package (an easy-to-use Windows Runtime API for immediate-mode 2D graphics rendering). For WinUI).

C++/WinRT-specific features

The C++/WinRT-specific features that Photo Editor demonstrates include:

Prerequisites

To get the latest updates to Windows and the development tools, and to help shape their development, join the Windows Insider Program.

Building and running the sample

  • Open the solution file (.sln) in Visual Studio.
  • From Visual Studio, either Start Without Debugging (Ctrl+F5) or Start Debugging (F5).

Code at a glance (C++/WinRT)

If you're just interested in code snippets for certain areas, and you don't want to browse or run the full sample, then check out the following files.

A custom runtime class that represents a photo.

The main page, which loads the photos from the Pictures Library and displays a tiled thumbnail view.

Tapping a photo from the MainPage thumbnail view takes you to the photo editor page, where Win2D effects are toggled, set, and chained together.

Code at a glance (C#)

If you're just interested in code snippets for certain areas and don't want to browse or run the full sample, check out the following files for examples of some highlighted features:

External libraries used in this sample

Changing the project's target platform version (C++/WinRT)

If you build the project on a given target platform version (TargetPlatformVersion in the project file), and then you retarget and rebuild, you might see this error message in Visual Studio: "error MIDL2003: [msg]redefinition [context]: ". If you do, then here are some options to resolve the issue.

  • Sometimes, the resolution is as simple as deleting the file \cpp-winui\PhotoEditor\<CONFIGURATION>\XamlMetaDataProvider.idl, and rebuilding.
  • If that doesn't clear the issue, then you can try deleting all temporary/generated folders and files, and rebuilding.
  • If you haven't made changes, then you can alternatively re-clone the repo, re-target, and build.