diff --git a/Samples/CameraCaptureUI/README.md b/Samples/CameraCaptureUI/README.md
new file mode 100644
index 000000000..614845220
--- /dev/null
+++ b/Samples/CameraCaptureUI/README.md
@@ -0,0 +1,57 @@
+---
+page_type: sample
+languages:
+- csharp
+- cppwinrt
+- cpp
+products:
+- windows
+- windows-app-sdk
+name: "CameraCaptureUI Sample"
+urlFragment: CameraCaptureUISample
+description: "Demonstrates how to capture photos and videos using the CameraCaptureUI API in WinAppSDK, showcasing how to integrate camera functionality into desktop apps."
+extendedZipContent:
+- path: LICENSE
+ target: LICENSE
+---
+
+
+# Camera Capture UI Sample Application
+
+This sample demonstrates how to capture photos and videos using the **CameraCaptureUI** API in a **WinUI3** app. It shows how to use the CameraCaptureUI API to launch the camera for photo and video captures within a desktop application. The sample highlights setting custom camera capture options such as format and resolution, handling successful captures, and displaying the captured media.
+
+> **Note**: This sample is targeted and tested for the **Windows App SDK 1.7 Experimental 1** and **Visual Studio 2022**.
+
+
+## Features
+
+This sample demonstrates:
+
+- **Photo Capture**: Capturing images with optional settings, including format and resolution.
+- **Video Capture**: Capturing videos, with options settings for format and maximum resolution.
+- **BitmapImage Display**: Displaying captured photos using `BitmapImage` in XAML.
+- **Media Playback**: Playing back captured videos using `MediaPlayerElement`.
+
+
+
+## Prerequisites
+
+
+* See [System requirements for Windows app development](https://docs.microsoft.com/windows/apps/windows-app-sdk/system-requirements).
+* Make sure that your development environment is set up correctly—see [Install tools for developing apps for Windows 10 and Windows 11](https://docs.microsoft.com/windows/apps/windows-app-sdk/set-up-your-development-environment).
+* The C# sample requires Visual Studio 2022 and .NET 6.
+
+## Building and Running the Sample
+
+* Open the solution file (`.sln`) in Visual Studio.
+* Press Ctrl+Shift+B, or select **Build** \> **Build Solution**.
+
+
+## Related Documentation and Code Samples
+* [Windows App SDK](https://docs.microsoft.com/windows/apps/windows-app-sdk/)
+* [CameraCaptureUI API Spec Documentation](https://github.com/microsoft/WindowsAppSDK/blob/main/specs/CameraCaptureUI/CameraCaptureUI.md)
+* [Windows Media Playback API](https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.mediaplayerelement?view=winrt-26100)
+* [BitmapImage Class Documentation](https://learn.microsoft.com/en-us/dotnet/api/system.windows.media.imaging.bitmapimage?view=windowsdesktop-8.0)
+
+
+
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui.sln b/Samples/CameraCaptureUI/cpp-winui/cpp-winui.sln
new file mode 100644
index 000000000..3e3d47cf6
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui.sln
@@ -0,0 +1,40 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.12.35514.174 d17.12
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-winui", "cpp-winui\cpp-winui.vcxproj", "{2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|arm64 = Debug|arm64
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|arm64 = Release|arm64
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|arm64.ActiveCfg = Debug|arm64
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|arm64.Build.0 = Debug|arm64
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|arm64.Deploy.0 = Debug|arm64
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|x64.ActiveCfg = Debug|x64
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|x64.Build.0 = Debug|x64
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|x64.Deploy.0 = Debug|x64
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|x86.ActiveCfg = Debug|Win32
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|x86.Build.0 = Debug|Win32
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|x86.Deploy.0 = Debug|Win32
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|arm64.ActiveCfg = Release|arm64
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|arm64.Build.0 = Release|arm64
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|arm64.Deploy.0 = Release|arm64
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|x64.ActiveCfg = Release|x64
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|x64.Build.0 = Release|x64
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|x64.Deploy.0 = Release|x64
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|x86.ActiveCfg = Release|Win32
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|x86.Build.0 = Release|Win32
+ {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|x86.Deploy.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml
new file mode 100644
index 000000000..15590f109
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml.cpp b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml.cpp
new file mode 100644
index 000000000..711946a44
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml.cpp
@@ -0,0 +1,38 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#include "pch.h"
+
+#include "App.xaml.h"
+#include "MainWindow.xaml.h"
+
+namespace winrt
+{
+ using namespace Windows::Foundation;
+ using namespace Microsoft::UI::Xaml;
+}
+
+namespace winrt::cpp_winui::implementation
+{
+ App::App()
+ {
+ InitializeComponent();
+
+#if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
+ UnhandledException([](winrt::IInspectable const&, winrt::UnhandledExceptionEventArgs const& e)
+ {
+ if (IsDebuggerPresent())
+ {
+ auto errorMessage = e.Message();
+ __debugbreak();
+ }
+ });
+#endif
+ }
+
+ void App::OnLaunched(winrt::LaunchActivatedEventArgs const&)
+ {
+ window = winrt::make();
+ window.Activate();
+ }
+}
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml.h b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml.h
new file mode 100644
index 000000000..4db951599
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml.h
@@ -0,0 +1,19 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#pragma once
+#include "App.xaml.g.h"
+#include "pch.h"
+
+namespace winrt::cpp_winui::implementation
+{
+ struct App : AppT
+ {
+ App();
+
+ void OnLaunched(Microsoft::UI::Xaml::LaunchActivatedEventArgs const&);
+
+ private:
+ Microsoft::UI::Xaml::Window window{ nullptr };
+ };
+}
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/SplashScreen.png b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/SplashScreen.png
new file mode 100644
index 000000000..184821318
Binary files /dev/null and b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/SplashScreen.png differ
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Square150x150Logo.png b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Square150x150Logo.png
new file mode 100644
index 000000000..a50c70379
Binary files /dev/null and b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Square150x150Logo.png differ
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Square44x44Logo.png b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Square44x44Logo.png
new file mode 100644
index 000000000..844b60c20
Binary files /dev/null and b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Square44x44Logo.png differ
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Wide310x150Logo.png b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Wide310x150Logo.png
new file mode 100644
index 000000000..b5d5f2c42
Binary files /dev/null and b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Wide310x150Logo.png differ
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/logo.png b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/logo.png
new file mode 100644
index 000000000..fd2293e7b
Binary files /dev/null and b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/logo.png differ
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/windows-sdk.ico b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/windows-sdk.ico
new file mode 100644
index 000000000..3ad20c7c2
Binary files /dev/null and b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/windows-sdk.ico differ
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml
new file mode 100644
index 000000000..9c5c0dfd7
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml.cpp b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml.cpp
new file mode 100644
index 000000000..833d3ab23
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml.cpp
@@ -0,0 +1,156 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#include "pch.h"
+#include "MainPage.xaml.h"
+#if __has_include("MainPage.g.cpp")
+#include "MainPage.g.cpp"
+#endif
+
+namespace winrt
+{
+ using namespace Microsoft::UI::Xaml;
+ using namespace Microsoft::UI::Xaml::Controls;
+ using namespace Microsoft::UI::Xaml::Media;
+ using namespace Microsoft::UI::Xaml::Media::Animation;
+ using namespace Microsoft::UI::Xaml::Navigation;
+ using namespace Windows::UI::Xaml::Interop;
+}
+
+namespace winrt::cpp_winui::implementation
+{
+ cpp_winui::MainPage MainPage::current{ nullptr };
+
+ MainPage::MainPage()
+ {
+ InitializeComponent();
+ MainPage::current = *this;
+ }
+
+ void MainPage::NotifyUser(hstring const& strMessage, InfoBarSeverity const& severity)
+ {
+ // If called from the UI thread, then update immediately.
+ // Otherwise, schedule a task on the UI thread to perform the update.
+ if (this->DispatcherQueue().HasThreadAccess())
+ {
+ UpdateStatus(strMessage, severity);
+ }
+ else
+ {
+ DispatcherQueue().TryEnqueue([strongThis = get_strong(), this, strMessage, severity]
+ { UpdateStatus(strMessage, severity); });
+ }
+ }
+
+ void MainPage::UpdateStatus(hstring const& strMessage, InfoBarSeverity severity)
+ {
+ infoBar().Message(strMessage);
+ infoBar().IsOpen(!strMessage.empty());
+ infoBar().Severity(severity);
+ }
+
+ void MainPage::NavView_Loaded(IInspectable const&, RoutedEventArgs const&)
+ {
+ for (auto&& s : Scenarios())
+ {
+ FontIcon fontIcon{};
+ fontIcon.FontFamily(winrt::FontFamily(L"Segoe MDL2 Assets"));
+ fontIcon.Glyph(L"\uE82D");
+
+ NavigationViewItem navViewItem{};
+ navViewItem.Content(box_value(s.Title));
+ navViewItem.Tag(box_value(s.ClassName));
+ navViewItem.Icon(fontIcon);
+ NavView().MenuItems().Append(navViewItem);
+ }
+
+ // NavView doesn't load any page by default, so load home page.
+ NavView().SelectedItem(NavView().MenuItems().GetAt(0));
+
+ // If navigation occurs on SelectionChanged, this isn't needed.
+ // Because we use ItemInvoked to navigate, we need to call Navigate
+ // here to load the home page.
+ if (Scenarios().Size() > 0)
+ {
+ NavView_Navigate(Scenarios().GetAt(0).ClassName, nullptr);
+ }
+ }
+
+
+ void MainPage::NavView_ItemInvoked(NavigationView const&, NavigationViewItemInvokedEventArgs const& args)
+ {
+ if (args.IsSettingsInvoked() == true)
+ {
+ hstring xamltypename = winrt::xaml_typename().Name;
+ NavView_Navigate(xamltypename, args.RecommendedNavigationTransitionInfo());
+ }
+ else if (args.InvokedItemContainer() != nullptr)
+ {
+ auto navItemTag = winrt::unbox_value(args.InvokedItemContainer().Tag());
+ if (navItemTag != L"")
+ {
+ NavView_Navigate(navItemTag, args.RecommendedNavigationTransitionInfo());
+ }
+ }
+ }
+
+ void MainPage::NavView_Navigate(hstring navItemTag, NavigationTransitionInfo const&)
+ {
+ TypeName pageType;
+
+ if (navItemTag == winrt::xaml_typename().Name)
+ {
+ pageType = winrt::xaml_typename();
+ }
+ else
+ {
+ pageType.Name = navItemTag;
+ pageType.Kind = TypeKind::Metadata;
+ }
+
+ // Get the page type before navigation so you can prevent duplicate
+ // entries in the backstack.
+ TypeName prePageType = ContentFrame().CurrentSourcePageType();
+
+ // Only navigate if the selected page isn't currently loaded.
+ if (prePageType.Name != pageType.Name)
+ {
+ DrillInNavigationTransitionInfo drillIn;
+ ContentFrame().Navigate(pageType, nullptr, drillIn);
+ }
+ }
+
+ void MainPage::NavView_BackRequested(NavigationView const&, NavigationViewBackRequestedEventArgs const&)
+ {
+ if (ContentFrame().CanGoBack())
+ {
+ ContentFrame().GoBack();
+ }
+ }
+
+ void MainPage::ContentFrame_Navigated(IInspectable const&, NavigationEventArgs const& e)
+ {
+ NavView().IsBackEnabled(ContentFrame().CanGoBack());
+
+ if (ContentFrame().SourcePageType().Name == winrt::xaml_typename().Name)
+ {
+ // SettingsItem is not part of NavView.MenuItems, and doesn't have a Tag.
+ NavView().SelectedItem((NavView().SettingsItem().as()));
+ NavView().Header(winrt::box_value(L"Settings"));
+ }
+ else
+ {
+ for (auto&& item : NavView().MenuItems())
+ {
+ auto navViewItem = item.try_as();
+ if (navViewItem != nullptr &&
+ winrt::unbox_value(navViewItem.Tag()) == e.SourcePageType().Name)
+ {
+ NavView().SelectedItem(navViewItem);
+ NavView().Header(navViewItem.Content());
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml.h b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml.h
new file mode 100644
index 000000000..23ce2b17d
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml.h
@@ -0,0 +1,33 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#pragma once
+#include "MainPage.g.h"
+
+namespace winrt::cpp_winui::implementation
+{
+ struct MainPage : MainPageT
+ {
+ MainPage();
+ static cpp_winui::MainPage Current() { return current; }
+ static Windows::Foundation::Collections::IVector Scenarios() { return scenariosInner; }
+ void NotifyUser(hstring const& strMessage, Microsoft::UI::Xaml::Controls::InfoBarSeverity const& severity);
+ void UpdateStatus(hstring const& strMessage, Microsoft::UI::Xaml::Controls::InfoBarSeverity severity);
+ void NavView_Loaded(Windows::Foundation::IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& e);
+ void NavView_ItemInvoked(Microsoft::UI::Xaml::Controls::NavigationView const& sender, Microsoft::UI::Xaml::Controls::NavigationViewItemInvokedEventArgs const& args);
+ void NavView_Navigate(hstring navItemTag, Microsoft::UI::Xaml::Media::Animation::NavigationTransitionInfo const& transitionInfo);
+ void NavView_BackRequested(Microsoft::UI::Xaml::Controls::NavigationView const& sender, Microsoft::UI::Xaml::Controls::NavigationViewBackRequestedEventArgs const& args);
+ void ContentFrame_Navigated(Windows::Foundation::IInspectable const& sender, Microsoft::UI::Xaml::Navigation::NavigationEventArgs const& e);
+
+ private:
+ static Windows::Foundation::Collections::IVector scenariosInner;
+ static cpp_winui::MainPage current;
+ };
+}
+
+namespace winrt::cpp_winui::factory_implementation
+{
+ struct MainPage : MainPageT
+ {
+ };
+}
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml
new file mode 100644
index 000000000..50419d214
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml.cpp b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml.cpp
new file mode 100644
index 000000000..9d9936532
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml.cpp
@@ -0,0 +1,89 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#include "pch.h"
+#include "MainWindow.xaml.h"
+#if __has_include("MainWindow.g.cpp")
+#include "MainWindow.g.cpp"
+
+#include "microsoft.ui.xaml.window.h"
+#include "SampleConfiguration.h"
+#endif
+
+namespace winrt
+{
+ using namespace Microsoft::UI::Xaml;
+}
+
+namespace winrt::cpp_winui::implementation
+{
+ MainWindow::MainWindow()
+ {
+ InitializeComponent();
+
+ Title(winrt::cpp_winui::SampleConfig::FeatureName);
+
+ HWND hwnd = GetWindowHandle();
+ LoadIcon(hwnd, L"windows-sdk.ico");
+ SetWindowSize(hwnd, 1050, 800);
+ PlacementCenterWindowInMonitorWin32(hwnd);
+ }
+
+ HWND MainWindow::GetWindowHandle()
+ {
+ if (_hwnd == nullptr)
+ {
+ Window window = *this;
+ window.as()->get_WindowHandle(&_hwnd);
+ }
+ return _hwnd;
+ }
+
+ void MainWindow::LoadIcon(HWND hwnd, wchar_t const* iconPath)
+ {
+ HANDLE hSmallIcon = LoadImageW(nullptr, iconPath, IMAGE_ICON,
+ GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
+ LR_LOADFROMFILE | LR_SHARED);
+ SendMessageW(hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast(hSmallIcon));
+
+ HANDLE hBigIcon = LoadImageW(nullptr, iconPath, IMAGE_ICON,
+ GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON),
+ LR_LOADFROMFILE | LR_SHARED);
+ SendMessageW(hwnd, WM_SETICON, ICON_BIG, reinterpret_cast(hBigIcon));
+ }
+
+ void MainWindow::SetWindowSize(HWND hwnd, int width, int height)
+ {
+ // Win32 uses pixels and WinUI 3 uses effective pixels, so you should apply the DPI scale factor
+ const UINT dpi = GetDpiForWindow(hwnd);
+ const float scalingFactor = static_cast(dpi) / 96;
+ const int widthScaled = static_cast(width * scalingFactor);
+ const int heightScaled = static_cast(height * scalingFactor);
+
+ SetWindowPos(hwnd, nullptr, 0, 0, widthScaled, heightScaled, SWP_NOMOVE | SWP_NOZORDER);
+ }
+
+ void MainWindow::PlacementCenterWindowInMonitorWin32(HWND hwnd)
+ {
+ RECT windowMontiorRectToAdjust;
+ GetWindowRect(hwnd, &windowMontiorRectToAdjust);
+ ClipOrCenterRectToMonitorWin32(windowMontiorRectToAdjust);
+ SetWindowPos(hwnd, nullptr, windowMontiorRectToAdjust.left,
+ windowMontiorRectToAdjust.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
+ }
+
+ void MainWindow::ClipOrCenterRectToMonitorWin32(RECT& adjustedWindowRect)
+ {
+ MONITORINFO mi{ sizeof(mi) };
+ GetMonitorInfoW(MonitorFromRect(&adjustedWindowRect, MONITOR_DEFAULTTONEAREST), &mi);
+
+ const auto& rcWork = mi.rcWork;
+ const int w = adjustedWindowRect.right - adjustedWindowRect.left;
+ const int h = adjustedWindowRect.bottom - adjustedWindowRect.top;
+
+ adjustedWindowRect.left = rcWork.left + (rcWork.right - rcWork.left - w) / 2;
+ adjustedWindowRect.top = rcWork.top + (rcWork.bottom - rcWork.top - h) / 2;
+ adjustedWindowRect.right = adjustedWindowRect.left + w;
+ adjustedWindowRect.bottom = adjustedWindowRect.top + h;
+ }
+}
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml.h b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml.h
new file mode 100644
index 000000000..7ad2a192a
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml.h
@@ -0,0 +1,29 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#pragma once
+#include "MainWindow.g.h"
+#include "pch.h"
+
+namespace winrt::cpp_winui::implementation
+{
+ struct MainWindow : MainWindowT
+ {
+ MainWindow();
+
+ private:
+ HWND _hwnd{ nullptr };
+ void SetWindowSize(HWND hwnd, const int width, const int height);
+ HWND GetWindowHandle();
+ void LoadIcon(HWND hwnd, wchar_t const* iconName);
+ void ClipOrCenterRectToMonitorWin32(RECT& rc);
+ void PlacementCenterWindowInMonitorWin32(HWND hwnd);
+ };
+}
+
+namespace winrt::cpp_winui::factory_implementation
+{
+ struct MainWindow : MainWindowT
+ {
+ };
+}
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Package.appxmanifest b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Package.appxmanifest
new file mode 100644
index 000000000..6efd2a9c5
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Package.appxmanifest
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+ cpp-winui
+ Microsoft Corporation
+ Assets\logo.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Project.idl b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Project.idl
new file mode 100644
index 000000000..7bb139a47
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Project.idl
@@ -0,0 +1,49 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+namespace cpp_winui
+{
+ /* The following code is scenario/feature-specific IDL.
+ Samples authors should modify these runtime classes as appropriate. */
+
+ [default_interface]
+ runtimeclass Scenario1_CapturePhoto : Microsoft.UI.Xaml.Controls.Page
+ {
+ Scenario1_CapturePhoto();
+ }
+
+ [default_interface]
+ runtimeclass Scenario2_CaptureVideo : Microsoft.UI.Xaml.Controls.Page
+ {
+ Scenario2_CaptureVideo();
+ }
+
+ /* The following code is template-specific IDL.
+ These runtime classes are the same across all C++/WinRT WinUI samples. */
+
+ runtimeclass MainPage : Microsoft.UI.Xaml.Controls.Page
+ {
+ MainPage();
+ static MainPage Current();
+ void NotifyUser(String strMessage, Microsoft.UI.Xaml.Controls.InfoBarSeverity severity);
+ }
+
+ // To use Scenario in a winrt::Windows::Foundation::Collections::IVector, Scenario should be a WinRT type
+ struct Scenario
+ {
+ String Title;
+ String ClassName;
+ };
+
+ [default_interface]
+ runtimeclass MainWindow : Microsoft.UI.Xaml.Window
+ {
+ MainWindow();
+ }
+
+ [default_interface]
+ runtimeclass SettingsPage : Microsoft.UI.Xaml.Controls.Page
+ {
+ SettingsPage();
+ }
+}
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SampleConfiguration.cpp b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SampleConfiguration.cpp
new file mode 100644
index 000000000..648011c90
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SampleConfiguration.cpp
@@ -0,0 +1,25 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#pragma once
+#include "pch.h"
+#include "SampleConfiguration.h"
+#include "MainPage.xaml.h"
+
+namespace winrt
+{
+ using namespace Microsoft::UI::Xaml;
+ using namespace Windows::Foundation::Collections;
+}
+
+namespace winrt::cpp_winui
+{
+ IVector implementation::MainPage::scenariosInner = single_threaded_observable_vector(
+ {
+ Scenario{ L"Capture Photo", hstring(name_of())},
+ Scenario{ L"Capture Video", hstring(name_of())}
+ });
+
+ hstring SampleConfig::FeatureName{ L"CameraCaptureUI_CPP_SAMPLE" };
+ ElementTheme SampleConfig::CurrentTheme{ ElementTheme::Default };
+}
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SampleConfiguration.h b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SampleConfiguration.h
new file mode 100644
index 000000000..c38a92976
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SampleConfiguration.h
@@ -0,0 +1,15 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#pragma once
+#include "pch.h"
+
+namespace winrt::cpp_winui
+{
+ struct SampleConfig
+ {
+ public:
+ static hstring FeatureName;
+ static Microsoft::UI::Xaml::ElementTheme CurrentTheme;
+ };
+}
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario1_CapturePhoto.xaml b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario1_CapturePhoto.xaml
new file mode 100644
index 000000000..dcf028e35
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario1_CapturePhoto.xaml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario1_CapturePhoto.xaml.cpp b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario1_CapturePhoto.xaml.cpp
new file mode 100644
index 000000000..cac04ab17
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario1_CapturePhoto.xaml.cpp
@@ -0,0 +1,74 @@
+#include "pch.h"
+#include "Scenario1_CapturePhoto.xaml.h"
+#if __has_include("Scenario1_CapturePhoto.g.cpp")
+#include "Scenario1_CapturePhoto.g.cpp"
+#endif
+
+namespace winrt
+{
+ using namespace Microsoft::UI::Xaml;
+ using namespace Microsoft::UI::Xaml::Controls;
+ using namespace Windows::Foundation;
+ using namespace Windows::Storage;
+ using namespace Windows::Storage::Streams;
+}
+
+namespace winrt::cpp_winui::implementation
+{
+ MainPage Scenario1_CapturePhoto::rootPage{ nullptr };
+
+ Scenario1_CapturePhoto::Scenario1_CapturePhoto()
+ {
+ InitializeComponent();
+ Scenario1_CapturePhoto::rootPage = MainPage::Current();
+ }
+
+ winrt::fire_and_forget Scenario1_CapturePhoto::CapturePhoto_Click(IInspectable const&, RoutedEventArgs const&)
+ {
+ auto parentWindow = ::GetForegroundWindow();
+ winrt::Microsoft::UI::WindowId windowId{ reinterpret_cast(parentWindow) };
+ winrt::Microsoft::Windows::Media::Capture::CameraCaptureUI cameraUI(windowId);
+
+ // Optionally, set photo settings such as format, aspect ratio, etc.
+ cameraUI.PhotoSettings().Format(winrt::Microsoft::Windows::Media::Capture::CameraCaptureUIPhotoFormat::Jpeg);
+
+ // -- Optional Parameters --
+ //cameraUI.PhotoSettings().MaxResolution(winrt::Microsoft::Windows::Media::Capture::CameraCaptureUIMaxPhotoResolution::HighestAvailable);
+ //cameraUI.PhotoSettings().CroppedAspectRatio(winrt::Windows::Foundation::Size(4, 3));
+ //cameraUI.PhotoSettings().CroppedSizeInPixels(winrt::Windows::Foundation::Size(200, 200));
+
+ // -- Notes --
+ // By default, AllowCropping is true.
+ // Don't specify both size and aspect ratio in the PhotoSettings, doing so will cause an invalid argument exception.
+ // PhotoSettings can't have a ratio or size specified with cropping disabled. Attempting to do so will result in an invalid argument exception.
+ // Start the photo capture operation
+
+ auto file = co_await cameraUI.CaptureFileAsync(winrt::Microsoft::Windows::Media::Capture::CameraCaptureUIMode::Photo);
+
+ // Check if a file was captured successfully
+ if (file)
+ {
+ rootPage.NotifyUser(L"Photo successfully captured!", InfoBarSeverity::Success);
+ // Get the file path of the captured image
+ winrt::hstring filePath = file.Path();
+ // Create a Uri from the file path
+ winrt::Uri fileUri(filePath);
+ // Open the file and display it in the Image control
+ auto fileStream = co_await file.OpenAsync(winrt::Windows::Storage::FileAccessMode::Read);
+ // Create a BitmapImage and set its source to the captured file's stream
+ winrt::Microsoft::UI::Xaml::Media::Imaging::BitmapImage bitmapImage;
+ bitmapImage.UriSource(fileUri);
+ CapturedImage().Source(bitmapImage);
+ }
+ else
+ {
+ // If the capture failed, update the button content to "Photo Capture Failed"
+ rootPage.NotifyUser(L"Photo Capture Failed", InfoBarSeverity::Error);
+ }
+ }
+
+ void Scenario1_CapturePhoto::ClearMessage_Click(IInspectable const&, RoutedEventArgs const&)
+ {
+ rootPage.NotifyUser(L"", InfoBarSeverity::Informational);
+ }
+}
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario1_CapturePhoto.xaml.h b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario1_CapturePhoto.xaml.h
new file mode 100644
index 000000000..d7fedad02
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario1_CapturePhoto.xaml.h
@@ -0,0 +1,25 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#pragma once
+
+#include "Scenario1_CapturePhoto.g.h"
+
+namespace winrt::cpp_winui::implementation
+{
+ struct Scenario1_CapturePhoto : Scenario1_CapturePhotoT
+ {
+ Scenario1_CapturePhoto();
+ winrt::fire_and_forget CapturePhoto_Click(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&);
+ void ClearMessage_Click(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&);
+ private:
+ static cpp_winui::MainPage rootPage;
+ };
+}
+
+namespace winrt::cpp_winui::factory_implementation
+{
+ struct Scenario1_CapturePhoto : Scenario1_CapturePhotoT
+ {
+ };
+}
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario2_CaptureVideo.xaml b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario2_CaptureVideo.xaml
new file mode 100644
index 000000000..060d07a4f
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario2_CaptureVideo.xaml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario2_CaptureVideo.xaml.cpp b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario2_CaptureVideo.xaml.cpp
new file mode 100644
index 000000000..c03521f79
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario2_CaptureVideo.xaml.cpp
@@ -0,0 +1,78 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#include "pch.h"
+#include "Scenario2_CaptureVideo.xaml.h"
+#if __has_include("Scenario2_CaptureVideo.g.cpp")
+#include "Scenario2_CaptureVideo.g.cpp"
+#endif
+
+namespace winrt
+{
+ using namespace Microsoft::UI::Xaml;
+ using namespace Microsoft::UI::Xaml::Controls;
+ using namespace Windows::Foundation;
+ using namespace Windows::Storage;
+ using namespace Windows::Storage::Streams;
+}
+
+namespace winrt::cpp_winui::implementation
+{
+ MainPage Scenario2_CaptureVideo::rootPage{ nullptr };
+
+ Scenario2_CaptureVideo::Scenario2_CaptureVideo()
+ {
+ InitializeComponent();
+ Scenario2_CaptureVideo::rootPage = MainPage::Current();
+ }
+ winrt::fire_and_forget Scenario2_CaptureVideo::CaptureVideo_Click(IInspectable const&, RoutedEventArgs const&)
+ {
+ auto parentWindow = ::GetForegroundWindow();
+ winrt::Microsoft::UI::WindowId windowId{ reinterpret_cast(parentWindow) };
+ winrt::Microsoft::Windows::Media::Capture::CameraCaptureUI cameraUI(windowId);
+
+ // Optionally, set video settings such as format, max resolution, trimming, etc.
+ cameraUI.VideoSettings().Format(winrt::Microsoft::Windows::Media::Capture::CameraCaptureUIVideoFormat::Mp4);
+
+ // -- Optional Parameters --
+ //cameraUI.VideoSettings().MaxDurationInSeconds(30);
+ //cameraUI.VideoSettings().MaxResolution(winrt::Microsoft::Windows::Media::Capture::CameraCaptureUIMaxVideoResolution::HighestAvailable);
+ //cameraUI.VideoSettings().AllowTrimming(true);
+
+ // -- Notes --
+ //By default, AllowTrimming is true.
+ //MaxDurationInSeconds must be a valid value(i.e., the duration should be in the range of 0 to UINT32_MAX).Specifying an invalid value will result in an invalid argument exception.
+ //MaxDurationInSeconds cannot be set if AllowTrimming is false.Attempting to do so will result in an invalid argument exception.
+
+ auto file = co_await cameraUI.CaptureFileAsync(winrt::Microsoft::Windows::Media::Capture::CameraCaptureUIMode::Video);
+
+ // Check if a file was captured successfully
+ if (file)
+ {
+ rootPage.NotifyUser(L"Video successfully captured!", InfoBarSeverity::Success);
+ //// Get the file path of the captured image
+ winrt::hstring filePath = file.Path();
+ // Create a stream for the captured file
+ auto fileStream = co_await file.OpenAsync(winrt::Windows::Storage::FileAccessMode::Read);
+ winrt::Windows::Media::Core::MediaSource mediaSource = winrt::Windows::Media::Core::MediaSource::CreateFromStream(fileStream, file.ContentType());
+ // Create a MediaPlayer
+ Windows::Media::Playback::MediaPlayer mediaPlayer = Windows::Media::Playback::MediaPlayer();
+ // Set the source for the MediaPlayer
+ mediaPlayer.Source(mediaSource);
+ // Set the MediaPlayer to the MediaPlayerElement
+ MediaPlayElement().SetMediaPlayer(mediaPlayer);
+ // Start playing the video
+ mediaPlayer.Play();
+ }
+ else
+ {
+ // If the capture failed, update the button content to "Photo Capture Failed"
+ rootPage.NotifyUser(L"Video Capture Failed", InfoBarSeverity::Error);
+ }
+ }
+
+ void Scenario2_CaptureVideo::ClearMessage_Click(IInspectable const&, RoutedEventArgs const&)
+ {
+ rootPage.NotifyUser(L"", InfoBarSeverity::Informational);
+ }
+}
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario2_CaptureVideo.xaml.h b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario2_CaptureVideo.xaml.h
new file mode 100644
index 000000000..8c451387e
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario2_CaptureVideo.xaml.h
@@ -0,0 +1,26 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#pragma once
+
+#include "Scenario2_CaptureVideo.g.h"
+
+namespace winrt::cpp_winui::implementation
+{
+ struct Scenario2_CaptureVideo : Scenario2_CaptureVideoT
+ {
+ Scenario2_CaptureVideo();
+ winrt::fire_and_forget CaptureVideo_Click(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&);
+ void ClearMessage_Click(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&);
+ private:
+ static cpp_winui::MainPage rootPage;
+ };
+}
+
+namespace winrt::cpp_winui::factory_implementation
+{
+ struct Scenario2_CaptureVideo : Scenario2_CaptureVideoT
+ {
+ };
+}
+
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SettingsPage.xaml b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SettingsPage.xaml
new file mode 100644
index 000000000..ec772c83a
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SettingsPage.xaml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+ Light
+
+
+
+
+ Dark
+
+
+
+
+ Default
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SettingsPage.xaml.cpp b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SettingsPage.xaml.cpp
new file mode 100644
index 000000000..d6ac01609
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SettingsPage.xaml.cpp
@@ -0,0 +1,51 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#include "pch.h"
+#include "SettingsPage.xaml.h"
+#if __has_include("SettingsPage.g.cpp")
+#include "SettingsPage.g.cpp"
+#endif
+#include
+
+namespace winrt
+{
+ using namespace Microsoft::UI::Xaml;
+ using namespace Microsoft::UI::Xaml::Controls;
+ using namespace Microsoft::UI::Xaml::Navigation;
+ using namespace Windows::Foundation;
+}
+
+namespace winrt::cpp_winui::implementation
+{
+ SettingsPage::SettingsPage()
+ {
+ InitializeComponent();
+ }
+
+ void SettingsPage::OnNavigatedTo(NavigationEventArgs const&)
+ {
+ for (UIElement&& c : themePanel().Children())
+ {
+ auto tag = c.as().Tag().as();
+ if (tag == SampleConfig::CurrentTheme)
+ {
+ auto radioButton = c.as();
+ radioButton.IsChecked(true);
+ }
+ }
+ }
+
+ void SettingsPage::OnThemeRadioButtonChecked(IInspectable const& sender, RoutedEventArgs const&)
+ {
+ auto radiobutton = sender.as();
+ auto selectedTheme = unbox_value(radiobutton.Tag());
+
+ auto content = MainPage::Current().Content().as();
+ if (content != nullptr)
+ {
+ content.RequestedTheme(selectedTheme);
+ SampleConfig::CurrentTheme = content.RequestedTheme();
+ }
+ }
+}
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SettingsPage.xaml.h b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SettingsPage.xaml.h
new file mode 100644
index 000000000..d732533d7
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SettingsPage.xaml.h
@@ -0,0 +1,23 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#pragma once
+
+#include "SettingsPage.g.h"
+
+namespace winrt::cpp_winui::implementation
+{
+ struct SettingsPage : SettingsPageT
+ {
+ SettingsPage();
+ void OnNavigatedTo(Microsoft::UI::Xaml::Navigation::NavigationEventArgs const& e);
+ void OnThemeRadioButtonChecked(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
+ };
+}
+
+namespace winrt::cpp_winui::factory_implementation
+{
+ struct SettingsPage : SettingsPageT
+ {
+ };
+}
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Styles.xaml b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Styles.xaml
new file mode 100644
index 000000000..9ad2c0e4e
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Styles.xaml
@@ -0,0 +1,132 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/app.manifest b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/app.manifest
new file mode 100644
index 000000000..4bcfb90bd
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/app.manifest
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+ true/PM
+ PerMonitorV2, PerMonitor
+
+
+
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/cpp-winui.vcxproj b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/cpp-winui.vcxproj
new file mode 100644
index 000000000..f2554ab72
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/cpp-winui.vcxproj
@@ -0,0 +1,261 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ true
+ {2d525b7c-dafb-477d-86ac-9d9cd85bd8bc}
+ cpp-winui
+ cpp_winui
+
+ $(RootNamespace)
+ en-US
+ 16.0
+ false
+ true
+ Windows Store
+ 10.0
+ 10.0
+ 10.0.17763.0
+ true
+ true
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Debug
+ arm64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+ Release
+ arm64
+
+
+
+ Application
+ v143
+ Unicode
+ true
+
+
+ true
+ true
+
+
+ false
+ true
+ false
+
+
+
+
+
+
+
+
+
+ Use
+ pch.h
+ $(IntDir)pch.pch
+ Level4
+ %(AdditionalOptions) /bigobj
+
+
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+
+
+
+ MainPage.xaml
+ Code
+
+
+
+ App.xaml
+
+
+ MainWindow.xaml
+
+
+
+ Scenario1_CapturePhoto.xaml
+ Code
+
+
+ Scenario2_CaptureVideo.xaml
+ Code
+
+
+ SettingsPage.xaml
+ Code
+
+
+
+
+
+ Designer
+
+
+
+ Designer
+
+
+ Designer
+
+
+ Designer
+
+
+ Designer
+
+
+
+
+ MainPage.xaml
+ Code
+
+
+ Create
+
+
+ App.xaml
+
+
+ MainWindow.xaml
+
+
+
+
+ Scenario1_CapturePhoto.xaml
+ Code
+
+
+ Scenario2_CaptureVideo.xaml
+ Code
+
+
+ SettingsPage.xaml
+ Code
+
+
+
+
+ Code
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/cpp-winui.vcxproj.filters b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/cpp-winui.vcxproj.filters
new file mode 100644
index 000000000..0b0ab81dc
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/cpp-winui.vcxproj.filters
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Assets
+
+
+ Assets
+
+
+ Assets
+
+
+ Assets
+
+
+ Assets
+
+
+ Assets
+
+
+
+
+ {$guid1}
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/packages.config b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/packages.config
new file mode 100644
index 000000000..26b86dc8c
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/packages.config
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/pch.cpp b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/pch.cpp
new file mode 100644
index 000000000..40e691ba7
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/pch.cpp
@@ -0,0 +1,4 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#include "pch.h"
diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/pch.h b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/pch.h
new file mode 100644
index 000000000..ceec9a7cc
--- /dev/null
+++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/pch.h
@@ -0,0 +1,39 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+#pragma once
+#include
+#include
+#include
+#include
+
+// Undefine GetCurrentTime macro to prevent
+// conflict with Storyboard::GetCurrentTime
+#undef GetCurrentTime
+
+#include
+#include
+#include
+#include //For using xaml_typename
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "winrt/Microsoft.Windows.Media.Capture.h"
+#include "winrt/Microsoft.UI.Windowing.h"
+#include "winrt/Windows.ApplicationModel.h"
+#include "Winrt/Microsoft.UI.Xaml.Media.Imaging.h"
+#include
+#include
+#include
+#include
+#include
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui.sln b/Samples/CameraCaptureUI/cswinui/cswinui.sln
new file mode 100644
index 000000000..8c1c3d796
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui.sln
@@ -0,0 +1,40 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.12.35514.174 d17.12
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cswinui", "cswinui\cswinui.csproj", "{CA9AB13B-0B64-4762-A3EE-397237E220E2}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|arm64 = Debug|arm64
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|arm64 = Release|arm64
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Debug|arm64.ActiveCfg = Debug|arm64
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Debug|arm64.Build.0 = Debug|arm64
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Debug|arm64.Deploy.0 = Debug|arm64
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Debug|x64.ActiveCfg = Debug|x64
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Debug|x64.Build.0 = Debug|x64
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Debug|x64.Deploy.0 = Debug|x64
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Debug|x86.ActiveCfg = Debug|x86
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Debug|x86.Build.0 = Debug|x86
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Debug|x86.Deploy.0 = Debug|x86
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Release|arm64.ActiveCfg = Release|arm64
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Release|arm64.Build.0 = Release|arm64
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Release|arm64.Deploy.0 = Release|arm64
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Release|x64.ActiveCfg = Release|x64
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Release|x64.Build.0 = Release|x64
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Release|x64.Deploy.0 = Release|x64
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Release|x86.ActiveCfg = Release|x86
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Release|x86.Build.0 = Release|x86
+ {CA9AB13B-0B64-4762-A3EE-397237E220E2}.Release|x86.Deploy.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/App.xaml b/Samples/CameraCaptureUI/cswinui/cswinui/App.xaml
new file mode 100644
index 000000000..85ef73b20
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/App.xaml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/App.xaml.cs b/Samples/CameraCaptureUI/cswinui/cswinui/App.xaml.cs
new file mode 100644
index 000000000..a86713f42
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/App.xaml.cs
@@ -0,0 +1,25 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+using Microsoft.UI.Xaml;
+
+namespace cswinui
+{
+ public partial class App : Application
+ {
+ private Window mainWindow;
+
+ public App()
+ {
+ this.InitializeComponent();
+ }
+
+ protected override void OnLaunched(LaunchActivatedEventArgs args)
+ {
+ mainWindow = new MainWindow();
+ mainWindow.Activate();
+ }
+
+ public Window MainWindow => mainWindow;
+ }
+}
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Assets/SplashScreen.png b/Samples/CameraCaptureUI/cswinui/cswinui/Assets/SplashScreen.png
new file mode 100644
index 000000000..184821318
Binary files /dev/null and b/Samples/CameraCaptureUI/cswinui/cswinui/Assets/SplashScreen.png differ
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Assets/Square150x150Logo.png b/Samples/CameraCaptureUI/cswinui/cswinui/Assets/Square150x150Logo.png
new file mode 100644
index 000000000..a50c70379
Binary files /dev/null and b/Samples/CameraCaptureUI/cswinui/cswinui/Assets/Square150x150Logo.png differ
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Assets/Square44x44Logo.png b/Samples/CameraCaptureUI/cswinui/cswinui/Assets/Square44x44Logo.png
new file mode 100644
index 000000000..844b60c20
Binary files /dev/null and b/Samples/CameraCaptureUI/cswinui/cswinui/Assets/Square44x44Logo.png differ
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Assets/Wide310x150Logo.png b/Samples/CameraCaptureUI/cswinui/cswinui/Assets/Wide310x150Logo.png
new file mode 100644
index 000000000..b5d5f2c42
Binary files /dev/null and b/Samples/CameraCaptureUI/cswinui/cswinui/Assets/Wide310x150Logo.png differ
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Assets/logo.png b/Samples/CameraCaptureUI/cswinui/cswinui/Assets/logo.png
new file mode 100644
index 000000000..fd2293e7b
Binary files /dev/null and b/Samples/CameraCaptureUI/cswinui/cswinui/Assets/logo.png differ
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Assets/windows-sdk.ico b/Samples/CameraCaptureUI/cswinui/cswinui/Assets/windows-sdk.ico
new file mode 100644
index 000000000..16b6a4021
Binary files /dev/null and b/Samples/CameraCaptureUI/cswinui/cswinui/Assets/windows-sdk.ico differ
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/MainPage.xaml b/Samples/CameraCaptureUI/cswinui/cswinui/MainPage.xaml
new file mode 100644
index 000000000..bbab966d9
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/MainPage.xaml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/MainPage.xaml.cs b/Samples/CameraCaptureUI/cswinui/cswinui/MainPage.xaml.cs
new file mode 100644
index 000000000..bd8e3ab2b
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/MainPage.xaml.cs
@@ -0,0 +1,149 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Navigation;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace cswinui
+{
+ public partial class MainPage : Page
+ {
+ public static MainPage Current;
+ public List Scenarios => this.scenarios;
+
+ public MainPage()
+ {
+ InitializeComponent();
+
+ // This is a static public property that allows downstream pages to get a handle to the MainPage instance
+ // in order to call methods that are in this class.
+ Current = this;
+ }
+
+ public void NotifyUser(string strMessage, InfoBarSeverity severity, bool isOpen = true)
+ {
+ // If called from the UI thread, then update immediately.
+ // Otherwise, schedule a task on the UI thread to perform the update.
+ if (DispatcherQueue.HasThreadAccess)
+ {
+ UpdateStatus(strMessage, severity, isOpen);
+ }
+ else
+ {
+ DispatcherQueue.TryEnqueue(() =>
+ {
+ UpdateStatus(strMessage, severity, isOpen);
+ });
+ }
+ }
+
+ private void UpdateStatus(string strMessage, InfoBarSeverity severity, bool isOpen)
+ {
+ infoBar.Message = strMessage;
+ infoBar.IsOpen = isOpen;
+ infoBar.Severity = severity;
+ }
+
+ private void NavView_Loaded(object sender, RoutedEventArgs e)
+ {
+ foreach (Scenario item in scenarios)
+ {
+ NavView.MenuItems.Add(new NavigationViewItem {
+ Content = item.Title,
+ Tag = item.ClassName,
+ Icon = new FontIcon() { FontFamily = new("Segoe MDL2 Assets"), Glyph = "\uE82D" }
+ });
+ }
+
+ // NavView doesn't load any page by default, so load home page.
+ NavView.SelectedItem = NavView.MenuItems[0];
+
+ // If navigation occurs on SelectionChanged, this isn't needed.
+ // Because we use ItemInvoked to navigate, we need to call Navigate
+ // here to load the home page.
+ if (scenarios is not null && scenarios.Count > 0)
+ {
+ NavView_Navigate(scenarios.First().ClassName, new Microsoft.UI.Xaml.Media.Animation.EntranceNavigationTransitionInfo());
+ }
+ }
+
+ private void NavView_Navigate(string navItemTag, Microsoft.UI.Xaml.Media.Animation.NavigationTransitionInfo transitionInfo)
+ {
+ Type page;
+
+ if (navItemTag == nameof(SettingsPage))
+ {
+ page = typeof(SettingsPage);
+ }
+ else
+ {
+ Scenario item = scenarios.First(p => p.ClassName.Equals(navItemTag));
+ page = Type.GetType(item.ClassName);
+ }
+
+ // Get the page type before navigation so you can prevent duplicate
+ // entries in the backstack.
+ var preNavPageType = ContentFrame.CurrentSourcePageType;
+
+ // Only navigate if the selected page isn't currently loaded.
+ if ((page is not null) && !Type.Equals(preNavPageType, page))
+ {
+ ContentFrame.Navigate(page, null, transitionInfo);
+ }
+ }
+
+ private void NavView_BackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args)
+ {
+ if (ContentFrame.CanGoBack)
+ {
+ ContentFrame.GoBack();
+ }
+ }
+
+ private void NavView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
+ {
+ var naViewItemInvoked = (NavigationViewItem)args.InvokedItemContainer;
+
+ if (args.IsSettingsInvoked)
+ {
+ NavView_Navigate(nameof(SettingsPage), args.RecommendedNavigationTransitionInfo);
+ }
+ else if (args.InvokedItemContainer is not null)
+ {
+ var navItemTag = args.InvokedItemContainer.Tag?.ToString();
+ if (!string.IsNullOrEmpty(navItemTag))
+ {
+ NavView_Navigate(navItemTag, new Microsoft.UI.Xaml.Media.Animation.EntranceNavigationTransitionInfo());
+ }
+ }
+ }
+
+ private void ContentFrame_Navigated(object sender, NavigationEventArgs e)
+ {
+ NavView.IsBackEnabled = ContentFrame.CanGoBack;
+
+ if (ContentFrame.SourcePageType == typeof(SettingsPage))
+ {
+ // SettingsItem is not part of NavView.MenuItems, and doesn't have a Tag.
+ NavView.SelectedItem = (NavigationViewItem)NavView.SettingsItem;
+ NavView.Header = "Settings";
+ }
+ else if (ContentFrame.SourcePageType != null)
+ {
+ var item = scenarios.First(p => p.ClassName == e.SourcePageType.FullName);
+ var menuItems = NavView.MenuItems;
+
+ NavView.SelectedItem = NavView.MenuItems
+ .OfType()
+ .First(n => n.Tag.Equals(item.ClassName));
+
+ NavView.Header =
+ ((NavigationViewItem)NavView.SelectedItem)?.Content?.ToString();
+ }
+ }
+ }
+}
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/MainWindow.xaml b/Samples/CameraCaptureUI/cswinui/cswinui/MainWindow.xaml
new file mode 100644
index 000000000..22566dfe0
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/MainWindow.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/MainWindow.xaml.cs b/Samples/CameraCaptureUI/cswinui/cswinui/MainWindow.xaml.cs
new file mode 100644
index 000000000..e5d53fd1f
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/MainWindow.xaml.cs
@@ -0,0 +1,95 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+using Microsoft.UI.Xaml;
+using System;
+using System.Runtime.InteropServices;
+using Windows.Win32.Foundation;
+using Windows.Win32.Graphics.Gdi;
+using Windows.Win32.UI.WindowsAndMessaging;
+using static Windows.Win32.PInvoke;
+
+namespace cswinui
+{
+ public partial class MainWindow : Window
+ {
+ public MainWindow()
+ {
+ this.InitializeComponent();
+
+ Title = SampleConfig.FeatureName;
+
+ HWND hwnd = (HWND)WinRT.Interop.WindowNative.GetWindowHandle(this);
+ LoadIcon(hwnd, "Assets/windows-sdk.ico");
+ SetWindowSize(hwnd, 1050, 800);
+ PlacementCenterWindowInMonitorWin32(hwnd);
+ }
+
+ private unsafe void LoadIcon(HWND hwnd, string iconName)
+ {
+ const int ICON_SMALL = 0;
+ const int ICON_BIG = 1;
+
+ fixed (char* nameLocal = iconName)
+ {
+ HANDLE smallIcon = LoadImage(default,
+ nameLocal,
+ GDI_IMAGE_TYPE.IMAGE_ICON,
+ GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CXSMICON),
+ GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CYSMICON),
+ IMAGE_FLAGS.LR_LOADFROMFILE | IMAGE_FLAGS.LR_SHARED);
+ SendMessage(hwnd, WM_SETICON, ICON_SMALL, smallIcon.Value);
+ }
+
+ fixed (char* nameLocal = iconName)
+ {
+ HANDLE bigIcon = LoadImage(default,
+ nameLocal,
+ GDI_IMAGE_TYPE.IMAGE_ICON,
+ GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CXSMICON),
+ GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CYSMICON),
+ IMAGE_FLAGS.LR_LOADFROMFILE | IMAGE_FLAGS.LR_SHARED);
+ SendMessage(hwnd, WM_SETICON, ICON_BIG, bigIcon.Value);
+ }
+ }
+
+ private void SetWindowSize(HWND hwnd, int width, int height)
+ {
+ // Win32 uses pixels and WinUI 3 uses effective pixels, so you should apply the DPI scale factor
+ uint dpi = GetDpiForWindow(hwnd);
+ float scalingFactor = (float)dpi / 96;
+ width = (int)(width * scalingFactor);
+ height = (int)(height * scalingFactor);
+
+ SetWindowPos(hwnd, default, 0, 0, width, height, SET_WINDOW_POS_FLAGS.SWP_NOMOVE | SET_WINDOW_POS_FLAGS.SWP_NOZORDER);
+ }
+
+ private void PlacementCenterWindowInMonitorWin32(HWND hwnd)
+ {
+ RECT windowMonitorRectToAdjust;
+ GetWindowRect(hwnd, out windowMonitorRectToAdjust);
+ ClipOrCenterRectToMonitorWin32(ref windowMonitorRectToAdjust);
+ SetWindowPos(hwnd, default, windowMonitorRectToAdjust.left,
+ windowMonitorRectToAdjust.top, 0, 0,
+ SET_WINDOW_POS_FLAGS.SWP_NOSIZE |
+ SET_WINDOW_POS_FLAGS.SWP_NOZORDER |
+ SET_WINDOW_POS_FLAGS.SWP_NOACTIVATE);
+ }
+
+ private void ClipOrCenterRectToMonitorWin32(ref RECT adjustedWindowRect)
+ {
+ MONITORINFO mi = new MONITORINFO();
+ mi.cbSize = (uint)Marshal.SizeOf();
+ GetMonitorInfo(MonitorFromRect(adjustedWindowRect, MONITOR_FROM_FLAGS.MONITOR_DEFAULTTONEAREST), ref mi);
+
+ RECT rcWork = mi.rcWork;
+ int w = adjustedWindowRect.right - adjustedWindowRect.left;
+ int h = adjustedWindowRect.bottom - adjustedWindowRect.top;
+
+ adjustedWindowRect.left = rcWork.left + (rcWork.right - rcWork.left - w) / 2;
+ adjustedWindowRect.top = rcWork.top + (rcWork.bottom - rcWork.top - h) / 2;
+ adjustedWindowRect.right = adjustedWindowRect.left + w;
+ adjustedWindowRect.bottom = adjustedWindowRect.top + h;
+ }
+ }
+}
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/NativeMethods.txt b/Samples/CameraCaptureUI/cswinui/cswinui/NativeMethods.txt
new file mode 100644
index 000000000..d5596147d
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/NativeMethods.txt
@@ -0,0 +1,12 @@
+GetDpiForWindow
+GetModuleHandle
+GetMonitorInfo
+GetSystemMetrics
+GetWindowRect
+LoadImage
+MONITORINFO
+MonitorFromRect
+RECT
+SendMessage
+SetWindowPos
+WM_SETICON
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Package.appxmanifest b/Samples/CameraCaptureUI/cswinui/cswinui/Package.appxmanifest
new file mode 100644
index 000000000..0fbf49c1a
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/Package.appxmanifest
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+ cswinui
+ Microsoft Corporation
+ Assets\logo.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Properties/PublishProfiles/win10-arm64.pubxml b/Samples/CameraCaptureUI/cswinui/cswinui/Properties/PublishProfiles/win10-arm64.pubxml
new file mode 100644
index 000000000..93f661786
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/Properties/PublishProfiles/win10-arm64.pubxml
@@ -0,0 +1,19 @@
+
+
+
+
+ FileSystem
+ arm64
+ win10-arm64
+ bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\
+ true
+ False
+ False
+ True
+
+
\ No newline at end of file
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Properties/PublishProfiles/win10-x64.pubxml b/Samples/CameraCaptureUI/cswinui/cswinui/Properties/PublishProfiles/win10-x64.pubxml
new file mode 100644
index 000000000..26ea7e55c
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/Properties/PublishProfiles/win10-x64.pubxml
@@ -0,0 +1,20 @@
+
+
+
+
+ FileSystem
+ x64
+ win10-x64
+ bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\
+ true
+ False
+ False
+ True
+
+
+
\ No newline at end of file
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Properties/PublishProfiles/win10-x86.pubxml b/Samples/CameraCaptureUI/cswinui/cswinui/Properties/PublishProfiles/win10-x86.pubxml
new file mode 100644
index 000000000..34d14d4d4
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/Properties/PublishProfiles/win10-x86.pubxml
@@ -0,0 +1,20 @@
+
+
+
+
+ FileSystem
+ x86
+ win10-x86
+ bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\
+ true
+ False
+ False
+ True
+
+
+
\ No newline at end of file
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Properties/launchSettings.json b/Samples/CameraCaptureUI/cswinui/cswinui/Properties/launchSettings.json
new file mode 100644
index 000000000..de856c1a9
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/Properties/launchSettings.json
@@ -0,0 +1,10 @@
+{
+ "profiles": {
+ "cswinui (Package)": {
+ "commandName": "MsixPackage"
+ },
+ "cswinui (Unpackaged)": {
+ "commandName": "Project"
+ }
+ }
+}
\ No newline at end of file
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/SampleConfiguration.cs b/Samples/CameraCaptureUI/cswinui/cswinui/SampleConfiguration.cs
new file mode 100644
index 000000000..04cd7616c
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/SampleConfiguration.cs
@@ -0,0 +1,30 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using System.Collections.Generic;
+
+namespace cswinui
+{
+ internal static class SampleConfig
+ {
+ public const string FeatureName = "CameraCaptureUI_CS_SAMPLE";
+ public static ElementTheme CurrentTheme = ElementTheme.Default;
+ }
+
+ public partial class MainPage : Page
+ {
+ private readonly List scenarios = new()
+ {
+ new Scenario() { Title = "Capture Photo", ClassName = typeof(Scenario1_CapturePhoto).FullName },
+ new Scenario() { Title = "Capture Video", ClassName = typeof(Scenario2_CaptureVideo).FullName }
+ };
+ }
+
+ public class Scenario
+ {
+ public string Title { get; set; }
+ public string ClassName { get; set; }
+ }
+}
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Scenario1_CapturePhoto.xaml b/Samples/CameraCaptureUI/cswinui/cswinui/Scenario1_CapturePhoto.xaml
new file mode 100644
index 000000000..5cc1c1e4b
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/Scenario1_CapturePhoto.xaml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Scenario1_CapturePhoto.xaml.cs b/Samples/CameraCaptureUI/cswinui/cswinui/Scenario1_CapturePhoto.xaml.cs
new file mode 100644
index 000000000..aa5d23824
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/Scenario1_CapturePhoto.xaml.cs
@@ -0,0 +1,77 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Media.Imaging;
+using Windows.Storage;
+using Microsoft.Windows.Media.Capture;
+using Microsoft.UI;
+using System;
+
+namespace cswinui
+{
+ public partial class Scenario1_CapturePhoto : Page
+ {
+ private MainPage rootPage = MainPage.Current;
+
+ public Scenario1_CapturePhoto()
+ {
+ this.InitializeComponent();
+ }
+
+ private async void CapturePhoto_Click(object sender, RoutedEventArgs e)
+ {
+ // We have exposed a public variable called MainWindow in App.xaml.cs to fetch the window.
+ var windowId = ((App)Application.Current).MainWindow.AppWindow.Id;
+ // Initialize CameraCaptureUI with a window
+ CameraCaptureUI cameraUI = new CameraCaptureUI(windowId);
+
+ // Optionally, set photo settings such as format, aspect ratio, etc.
+ cameraUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;
+
+ // -- Optional parameters for photo capture --
+ //cameraUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.HighestAvailable;
+ //cameraUI.PhotoSettings.CroppedAspectRatio = new Windows.Foundation.Size(16, 9);
+ //cameraUI.PhotoSettings.CroppedSizeInPixels = new Windows.Foundation.Size(200, 200);
+
+ // -- Notes --
+ //By default, AllowTrimming is true.
+ //MaxDurationInSeconds must be a valid value(i.e., the duration should be in the range of 0 to UINT32_MAX).Specifying an invalid value will result in an invalid argument exception.
+ //MaxDurationInSeconds cannot be set if AllowTrimming is false.Attempting to do so will result in an invalid argument exception.
+
+ // Capture the photo asynchronously
+ var file = await cameraUI.CaptureFileAsync(CameraCaptureUIMode.Photo);
+
+ // Check if a file was captured successfully
+ if (file != null)
+ {
+ rootPage.NotifyUser("Photo successfully captured!", InfoBarSeverity.Success);
+
+ // Get the file path of the captured image
+ string filePath = file.Path;
+
+ // Create a Uri from the file path
+ Uri fileUri = new Uri(filePath);
+
+ // Open the file and display it in the Image control
+ var fileStream = await file.OpenAsync(FileAccessMode.Read);
+
+ // Create a BitmapImage and set its source to the captured file's stream
+ BitmapImage bitmapImage = new BitmapImage();
+ bitmapImage.UriSource = fileUri;
+ CapturedImage.Source = bitmapImage;
+ }
+ else
+ {
+ // If the capture failed, notify the user
+ rootPage.NotifyUser("Photo Capture Failed", InfoBarSeverity.Error);
+ }
+ }
+
+ private void ClearMessage_Click(object sender, RoutedEventArgs e)
+ {
+ rootPage.NotifyUser("", InfoBarSeverity.Informational, false);
+ }
+ }
+}
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Scenario2_CaptureVideo.xaml b/Samples/CameraCaptureUI/cswinui/cswinui/Scenario2_CaptureVideo.xaml
new file mode 100644
index 000000000..4d09383b4
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/Scenario2_CaptureVideo.xaml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Scenario2_CaptureVideo.xaml.cs b/Samples/CameraCaptureUI/cswinui/cswinui/Scenario2_CaptureVideo.xaml.cs
new file mode 100644
index 000000000..0ee8994e4
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/Scenario2_CaptureVideo.xaml.cs
@@ -0,0 +1,87 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Media.Imaging;
+using Windows.Storage;
+using Windows.Storage.Streams;
+using Microsoft.Windows.Media.Capture;
+using Windows.Media.Core;
+using Windows.Media.Playback;
+using Windows.Foundation;
+using WinRT.Interop;
+using System;
+
+namespace cswinui
+{
+ public partial class Scenario2_CaptureVideo : Page
+ {
+ private MainPage rootPage;
+ public Scenario2_CaptureVideo()
+ {
+ this.InitializeComponent();
+ rootPage = MainPage.Current;
+ }
+ private async void CaptureVideo_Click(object sender, RoutedEventArgs e)
+ {
+ // We have exposed a public variable called MainWindow in App.xaml.cs to fetch the window.
+ var windowId = ((App)Application.Current).MainWindow.AppWindow.Id;
+ // Initialize CameraCaptureUI with a window handle
+ CameraCaptureUI cameraUI = new CameraCaptureUI(windowId);
+
+ // Optionally set video settings such as format, resolution, etc.
+ cameraUI.VideoSettings.Format = CameraCaptureUIVideoFormat.Mp4;
+
+ // -- Optional parameters for video capture --
+ cameraUI.VideoSettings.MaxDurationInSeconds = 30;
+ cameraUI.VideoSettings.MaxResolution = CameraCaptureUIMaxVideoResolution.HighestAvailable;
+ cameraUI.VideoSettings.AllowTrimming = true;
+
+ // -- Notes --
+ //By default, AllowTrimming is true.
+ //MaxDurationInSeconds must be a valid value(i.e., the duration should be in the range of 0 to UINT32_MAX).Specifying an invalid value will result in an invalid argument exception.
+ //MaxDurationInSeconds cannot be set if AllowTrimming is false.Attempting to do so will result in an invalid argument exception.
+
+ //Capture the video asynchronously
+ var file = await cameraUI.CaptureFileAsync(CameraCaptureUIMode.Video);
+
+ // Check if the capture was successful
+ if (file != null)
+ {
+ rootPage.NotifyUser("Video successfully captured!", InfoBarSeverity.Success);
+
+ // Get the file path of the captured video
+ string filePath = file.Path;
+
+ // Open the file as a stream
+ var fileStream = await file.OpenAsync(FileAccessMode.Read);
+
+ // Create a MediaSource from the file stream
+ var mediaSource = MediaSource.CreateFromStream(fileStream, file.ContentType);
+
+ // Create a MediaPlayer to play the video
+ var mediaPlayer = new MediaPlayer();
+
+ // Set the media source for the MediaPlayer
+ mediaPlayer.Source = mediaSource;
+
+ // Set the MediaPlayer to the MediaPlayerElement control in the UI
+ MediaPlayElement.SetMediaPlayer(mediaPlayer);
+
+ // Play the video
+ mediaPlayer.Play();
+ }
+ else
+ {
+ // If the capture failed, notify the user
+ rootPage.NotifyUser("Video Capture Failed", InfoBarSeverity.Error);
+ }
+ return;
+ }
+ private void ClearMessage_Click(object sender, RoutedEventArgs e)
+ {
+ rootPage.NotifyUser("", InfoBarSeverity.Informational, false);
+ }
+ }
+}
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/SettingsPage.xaml b/Samples/CameraCaptureUI/cswinui/cswinui/SettingsPage.xaml
new file mode 100644
index 000000000..feaad7312
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/SettingsPage.xaml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+ Light
+
+
+
+
+ Dark
+
+
+
+
+ Default
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/SettingsPage.xaml.cs b/Samples/CameraCaptureUI/cswinui/cswinui/SettingsPage.xaml.cs
new file mode 100644
index 000000000..13e93ca1a
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/SettingsPage.xaml.cs
@@ -0,0 +1,36 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Navigation;
+using System.Linq;
+
+namespace cswinui
+{
+ public partial class SettingsPage : Page
+ {
+ public SettingsPage()
+ {
+ this.InitializeComponent();
+ }
+
+ protected override void OnNavigatedTo(NavigationEventArgs e)
+ {
+ themePanel.Children.Cast().First(c => (ElementTheme)c.Tag == SampleConfig.CurrentTheme).IsChecked = true;
+ base.OnNavigatedTo(e);
+ }
+
+ private void OnThemeRadioButtonChecked(object sender, RoutedEventArgs e)
+ {
+ ElementTheme selectedTheme = (ElementTheme)((RadioButton)sender).Tag;
+
+ Grid content = MainPage.Current.Content as Grid;
+ if (content is not null)
+ {
+ content.RequestedTheme = selectedTheme;
+ SampleConfig.CurrentTheme = content.RequestedTheme;
+ }
+ }
+ }
+}
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/Styles.xaml b/Samples/CameraCaptureUI/cswinui/cswinui/Styles.xaml
new file mode 100644
index 000000000..6799b878e
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/Styles.xaml
@@ -0,0 +1,133 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/app.manifest b/Samples/CameraCaptureUI/cswinui/cswinui/app.manifest
new file mode 100644
index 000000000..54d763a3e
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/app.manifest
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+ true/PM
+ PerMonitorV2, PerMonitor
+
+
+
diff --git a/Samples/CameraCaptureUI/cswinui/cswinui/cswinui.csproj b/Samples/CameraCaptureUI/cswinui/cswinui/cswinui.csproj
new file mode 100644
index 000000000..e1c8de5f6
--- /dev/null
+++ b/Samples/CameraCaptureUI/cswinui/cswinui/cswinui.csproj
@@ -0,0 +1,42 @@
+
+
+ WinExe
+ net6.0-windows10.0.19041.0
+ 10.0.17763.0
+ cswinui
+ app.manifest
+ x86;x64;arm64
+ win10-x86;win10-x64;win10-arm64
+ true
+ true
+ Properties\PublishProfiles\win10-$(Platform).pubxml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/StoragePickers/README.md b/Samples/StoragePickers/README.md
new file mode 100644
index 000000000..d71eee3f2
--- /dev/null
+++ b/Samples/StoragePickers/README.md
@@ -0,0 +1,94 @@
+## The Storage Pickers Samples
+
+- Demonstrates the `Microsoft.Windows.Storage.Pickers` APIs inside a Windows App SDK app.
+- Targets Windows App SDK **1.8 or later**.
+- Three tabs showcase `FileOpenPicker`, `FileSavePicker`, and `FolderPicker` usage end to end.
+
+## 📸 Screenshot of App Layout
+
+
+
+## Deploy the Sample Packaged App Locally
+
+1. Open `cpp-sample/FilePickersAppSinglePackaged.sln` or `cs-sample/FilePickersAppSinglePackaged.sln` in Visual Studio, right click on the project, select "Package and Publish" > "Create App Package"
+
+
+
+2. Select Sideloading > Next
+
+
+
+3. Create and Trust your own test certification
+
+
+
+
+
+4. Create package
+
+
+
+5. Open the built result
+
+
+
+5. Run Install.ps1 in powershell
+
+
+
+*Note:*
+
+If encountering error like below:
+
+> Add-AppxPackage: Cannot find path 'C:\FilePickersAppSinglePackaged_1.0.1.0_x64_Debug_Test\Dependencies\x86\Microsoft.VCLibs.x86.Debug.14.00.appx C:\FilePickersAppSinglePackaged_1.0.1.0_x64_Debug_Test\Dependencies\x86\Microsoft.VCLibs.x86.Debug.14.00.Desktop.appx C:\FilePickersAppSinglePackaged_1.0.1.0_x64_Debug_Test\Dependencies\x64\Microsoft.VCLibs.x64.Debug.14.00.appx C:\FilePickersAppSinglePackaged_1.0.1.0_x64_Debug_Test\Dependencies\x64\Microsoft.VCLibs.x64.Debug.14.00.Desktop.appx' because it does not exist.
+
+Replace lines 483-491 in `Add-AppDevPackage.ps1` with below script and try again:
+
+```ps
+if ($DependencyPackages.FullName.Count -gt 0)
+{
+ Write-Host $UiStrings.DependenciesFound
+ $DependencyPackages.FullName
+
+
+ # Install dependencies one by one first
+ foreach ($dep in $DependencyPackages.FullName) {
+ echo "Installing dependency: $dep"
+ try {
+ Add-AppxPackage -Path $dep -ForceApplicationShutdown
+ echo "Successfully installed: $dep"
+ } catch {
+ echo "Failed to install dependency: $dep - $($_.Exception.Message)"
+ }
+ }
+
+ # Now install the main package
+ echo "Installing main package: $($DeveloperPackagePath.FullName)"
+ Add-AppxPackage -Path $DeveloperPackagePath.FullName -ForceApplicationShutdown
+}
+```
+
+Screenshot of this error:
+
+
+Screenshot of this mitigation:
+
+
+
+With the dependency *.appx files correctly installed, the project should be debugged in Visual Studio smoothly.
+
+
+
+
+## 🚀 Run
+
+1. Open `cpp-sample/FilePickersAppSinglePackaged.sln` or `cs-sample/FilePickersAppSinglePackaged.sln` in Visual Studio.
+1. Restore NuGet packages and ensure the Windows App SDK 1.8 runtime is installed locally.
+1. Build and run.
+
+
+## More to explore
+
+- [Microsoft.Windows.Storage.Pickers Namespace](https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.windows.storage.pickers)
+- [Design Specs of Microsoft.Windows.Storage.Pickers](https://github.com/microsoft/WindowsAppSDK/blob/release/1.8-stable/specs/Storage.Pickers/Microsoft.Windows.Storage.Pickers.md)
+- [Windows App SDK](https://github.com/microsoft/WindowsAppSDK/)
diff --git a/Samples/StoragePickers/cpp-sample/App.xaml b/Samples/StoragePickers/cpp-sample/App.xaml
new file mode 100644
index 000000000..5a11fec41
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/App.xaml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/StoragePickers/cpp-sample/App.xaml.cpp b/Samples/StoragePickers/cpp-sample/App.xaml.cpp
new file mode 100644
index 000000000..673e30140
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/App.xaml.cpp
@@ -0,0 +1,43 @@
+#include "pch.h"
+#include "App.xaml.h"
+#include "MainWindow.xaml.h"
+
+using namespace winrt;
+using namespace Microsoft::UI::Xaml;
+
+// To learn more about WinUI, the WinUI project structure,
+// and more about our project templates, see: http://aka.ms/winui-project-info.
+
+namespace winrt::FilePickersAppSinglePackaged::implementation
+{
+ ///
+ /// Initializes the singleton application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ ///
+ App::App()
+ {
+ // Xaml objects should not call InitializeComponent during construction.
+ // See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
+
+#if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
+ UnhandledException([](IInspectable const&, UnhandledExceptionEventArgs const& e)
+ {
+ if (IsDebuggerPresent())
+ {
+ auto errorMessage = e.Message();
+ __debugbreak();
+ }
+ });
+#endif
+ }
+
+ ///
+ /// Invoked when the application is launched.
+ ///
+ /// Details about the launch request and process.
+ void App::OnLaunched([[maybe_unused]] LaunchActivatedEventArgs const& e)
+ {
+ window = make();
+ window.Activate();
+ }
+}
diff --git a/Samples/StoragePickers/cpp-sample/App.xaml.h b/Samples/StoragePickers/cpp-sample/App.xaml.h
new file mode 100644
index 000000000..bf0d7c789
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/App.xaml.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "App.xaml.g.h"
+
+namespace winrt::FilePickersAppSinglePackaged::implementation
+{
+ struct App : AppT
+ {
+ App();
+
+ void OnLaunched(Microsoft::UI::Xaml::LaunchActivatedEventArgs const&);
+
+ private:
+ winrt::Microsoft::UI::Xaml::Window window{ nullptr };
+ };
+}
diff --git a/Samples/StoragePickers/cpp-sample/Assets/LockScreenLogo.scale-200.png b/Samples/StoragePickers/cpp-sample/Assets/LockScreenLogo.scale-200.png
new file mode 100644
index 000000000..7440f0d4b
Binary files /dev/null and b/Samples/StoragePickers/cpp-sample/Assets/LockScreenLogo.scale-200.png differ
diff --git a/Samples/StoragePickers/cpp-sample/Assets/SplashScreen.scale-200.png b/Samples/StoragePickers/cpp-sample/Assets/SplashScreen.scale-200.png
new file mode 100644
index 000000000..32f486a86
Binary files /dev/null and b/Samples/StoragePickers/cpp-sample/Assets/SplashScreen.scale-200.png differ
diff --git a/Samples/StoragePickers/cpp-sample/Assets/Square150x150Logo.scale-200.png b/Samples/StoragePickers/cpp-sample/Assets/Square150x150Logo.scale-200.png
new file mode 100644
index 000000000..53ee3777e
Binary files /dev/null and b/Samples/StoragePickers/cpp-sample/Assets/Square150x150Logo.scale-200.png differ
diff --git a/Samples/StoragePickers/cpp-sample/Assets/Square44x44Logo.scale-200.png b/Samples/StoragePickers/cpp-sample/Assets/Square44x44Logo.scale-200.png
new file mode 100644
index 000000000..f713bba67
Binary files /dev/null and b/Samples/StoragePickers/cpp-sample/Assets/Square44x44Logo.scale-200.png differ
diff --git a/Samples/StoragePickers/cpp-sample/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/Samples/StoragePickers/cpp-sample/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
new file mode 100644
index 000000000..dc9f5bea0
Binary files /dev/null and b/Samples/StoragePickers/cpp-sample/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ
diff --git a/Samples/StoragePickers/cpp-sample/Assets/StoreLogo.png b/Samples/StoragePickers/cpp-sample/Assets/StoreLogo.png
new file mode 100644
index 000000000..a4586f26b
Binary files /dev/null and b/Samples/StoragePickers/cpp-sample/Assets/StoreLogo.png differ
diff --git a/Samples/StoragePickers/cpp-sample/Assets/Wide310x150Logo.scale-200.png b/Samples/StoragePickers/cpp-sample/Assets/Wide310x150Logo.scale-200.png
new file mode 100644
index 000000000..8b4a5d0dd
Binary files /dev/null and b/Samples/StoragePickers/cpp-sample/Assets/Wide310x150Logo.scale-200.png differ
diff --git a/Samples/StoragePickers/cpp-sample/FilePickersAppSinglePackaged.sln b/Samples/StoragePickers/cpp-sample/FilePickersAppSinglePackaged.sln
new file mode 100644
index 000000000..cb1b06ddf
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/FilePickersAppSinglePackaged.sln
@@ -0,0 +1,40 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.12.35707.178 d17.12
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FilePickersAppSinglePackaged", "FilePickersAppSinglePackaged.vcxproj", "{FC188327-1E71-4DC4-9B57-EB2A2CACEE12}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|ARM64 = Debug|ARM64
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|ARM64 = Release|ARM64
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Debug|ARM64.Build.0 = Debug|ARM64
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Debug|ARM64.Deploy.0 = Debug|ARM64
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Debug|x64.ActiveCfg = Debug|x64
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Debug|x64.Build.0 = Debug|x64
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Debug|x64.Deploy.0 = Debug|x64
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Debug|x86.ActiveCfg = Debug|Win32
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Debug|x86.Build.0 = Debug|Win32
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Debug|x86.Deploy.0 = Debug|Win32
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Release|ARM64.ActiveCfg = Release|ARM64
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Release|ARM64.Build.0 = Release|ARM64
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Release|ARM64.Deploy.0 = Release|ARM64
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Release|x64.ActiveCfg = Release|x64
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Release|x64.Build.0 = Release|x64
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Release|x64.Deploy.0 = Release|x64
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Release|x86.ActiveCfg = Release|Win32
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Release|x86.Build.0 = Release|Win32
+ {FC188327-1E71-4DC4-9B57-EB2A2CACEE12}.Release|x86.Deploy.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/StoragePickers/cpp-sample/FilePickersAppSinglePackaged.vcxproj b/Samples/StoragePickers/cpp-sample/FilePickersAppSinglePackaged.vcxproj
new file mode 100644
index 000000000..ba8b94708
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/FilePickersAppSinglePackaged.vcxproj
@@ -0,0 +1,240 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ true
+ {fc188327-1e71-4dc4-9b57-eb2a2cacee12}
+ FilePickersAppSinglePackaged
+ FilePickersAppSinglePackaged
+
+ $(RootNamespace)
+ en-US
+ 16.0
+ false
+ true
+ Windows Store
+ 10.0
+ 10.0
+ 10.0.17763.0
+ true
+ true
+ true
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Debug
+ ARM64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+ Release
+ ARM64
+
+
+
+ Application
+ v143
+ Unicode
+ true
+
+
+ true
+ true
+
+
+ false
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+ Use
+ pch.h
+ $(IntDir)pch.pch
+ Level4
+ %(AdditionalOptions) /bigobj
+
+
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ true
+ true
+
+
+
+
+ Designer
+
+
+
+
+
+
+
+
+ App.xaml
+
+
+ MainWindow.xaml
+
+
+
+
+
+
+
+
+ Create
+
+
+ App.xaml
+
+
+ MainWindow.xaml
+
+
+
+
+
+ Code
+ MainWindow.xaml
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Samples/StoragePickers/cpp-sample/FilePickersAppSinglePackaged.vcxproj.filters b/Samples/StoragePickers/cpp-sample/FilePickersAppSinglePackaged.vcxproj.filters
new file mode 100644
index 000000000..d10d1473d
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/FilePickersAppSinglePackaged.vcxproj.filters
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Assets
+
+
+ Assets
+
+
+ Assets
+
+
+ Assets
+
+
+ Assets
+
+
+ Assets
+
+
+ Assets
+
+
+
+
+ {fc188327-1e71-4dc4-9b57-eb2a2cacee12}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Samples/StoragePickers/cpp-sample/MainWindow.idl b/Samples/StoragePickers/cpp-sample/MainWindow.idl
new file mode 100644
index 000000000..2c7202940
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/MainWindow.idl
@@ -0,0 +1,8 @@
+namespace FilePickersAppSinglePackaged
+{
+ [default_interface]
+ runtimeclass MainWindow : Microsoft.UI.Xaml.Window
+ {
+ MainWindow();
+ }
+}
diff --git a/Samples/StoragePickers/cpp-sample/MainWindow.xaml b/Samples/StoragePickers/cpp-sample/MainWindow.xaml
new file mode 100644
index 000000000..0bce46907
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/MainWindow.xaml
@@ -0,0 +1,180 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/StoragePickers/cpp-sample/MainWindow.xaml.cpp b/Samples/StoragePickers/cpp-sample/MainWindow.xaml.cpp
new file mode 100644
index 000000000..2ca82bc4c
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/MainWindow.xaml.cpp
@@ -0,0 +1,412 @@
+#include "pch.h"
+#include "MainWindow.xaml.h"
+#if __has_include("MainWindow.g.cpp")
+#include "MainWindow.g.cpp"
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+using namespace winrt;
+using namespace Microsoft::UI::Xaml;
+using namespace Microsoft::UI::Windowing;
+using namespace Microsoft::Windows::Storage::Pickers;
+using namespace Windows::Data::Json;
+
+namespace
+{
+ std::wstring TrimString(std::wstring_view text)
+ {
+ auto start = text.find_first_not_of(L" \t\r\n'\"");
+ if (start == std::wstring_view::npos)
+ {
+ return {};
+ }
+
+ auto end = text.find_last_not_of(L" \t\r\n'\"");
+ return std::wstring{ text.substr(start, end - start + 1) };
+ }
+
+ bool IsChecked(Microsoft::UI::Xaml::Controls::CheckBox const& checkbox)
+ {
+ if (auto value = checkbox.IsChecked())
+ {
+ return value.Value();
+ }
+
+ return false;
+ }
+
+ std::wstring FileNameFromPath(std::wstring_view path)
+ {
+ if (path.empty())
+ {
+ return {};
+ }
+
+ std::filesystem::path fsPath{ path };
+ return fsPath.filename().wstring();
+ }
+}
+
+namespace winrt::FilePickersAppSinglePackaged::implementation
+{
+ MainWindow::MainWindow()
+ {
+ InitializeComponent();
+ Title(L"File Pickers Sample App");
+
+ if (auto appWindow = this->AppWindow())
+ {
+ appWindow.Resize({ 1800, 1100 });
+ }
+ }
+
+ void MainWindow::LogResult(winrt::hstring const& message)
+ {
+ using namespace std::chrono;
+
+ auto now = system_clock::now();
+ auto rawTime = system_clock::to_time_t(now);
+ tm localTime{};
+ localtime_s(&localTime, &rawTime);
+
+ std::wstringstream timestampStream;
+ timestampStream << std::put_time(&localTime, L"%H:%M:%S");
+
+ std::wstring existing{ ResultsTextBlock().Text().c_str() };
+
+ std::wstring newEntry;
+ newEntry.reserve(existing.size() + message.size() + 16);
+ newEntry.append(L"[");
+ newEntry.append(timestampStream.str());
+ newEntry.append(L"] ");
+ newEntry.append(message.c_str());
+ newEntry.append(L"\n");
+ newEntry.append(existing);
+
+ ResultsTextBlock().Text(winrt::hstring{ newEntry });
+ }
+
+ PickerLocationId MainWindow::GetSelectedNewLocationId()
+ {
+ switch (StartLocationComboBox().SelectedIndex())
+ {
+ case 0: return PickerLocationId::DocumentsLibrary;
+ case 1: return PickerLocationId::ComputerFolder;
+ case 2: return PickerLocationId::Desktop;
+ case 3: return PickerLocationId::Downloads;
+
+ // HomeGroup is excluded from the new PickerLocationId enum. This example demonstrates how the error would look like.
+ case 4: return static_cast(4);
+
+ case 5: return PickerLocationId::MusicLibrary;
+ case 6: return PickerLocationId::PicturesLibrary;
+ case 7: return PickerLocationId::VideosLibrary;
+ case 8: return PickerLocationId::Objects3D;
+ case 9: return PickerLocationId::Unspecified;
+ case 10: return static_cast(10);
+ default: throw hresult_invalid_argument(L"Invalid location selected");
+ }
+ }
+
+ PickerViewMode MainWindow::GetSelectedNewViewMode()
+ {
+ switch (ViewModeComboBox().SelectedIndex())
+ {
+ case 0: return PickerViewMode::List;
+ case 1: return PickerViewMode::Thumbnail;
+ case 2: return static_cast(2);
+ default: throw hresult_invalid_argument(L"Invalid view mode selected");
+ }
+ }
+
+ std::vector MainWindow::GetFileFilters()
+ {
+ std::wstring text{ FileTypeFilterInput().Text().c_str() };
+
+ std::vector filters;
+
+ std::wstringstream stream{ text };
+ std::wstring item;
+ while (std::getline(stream, item, L','))
+ {
+ auto trimmed = TrimString(item);
+ if (!trimmed.empty())
+ {
+ filters.emplace_back(trimmed);
+ }
+ }
+
+ if (filters.empty())
+ {
+ filters.emplace_back(L"*");
+ }
+
+ return filters;
+ }
+
+ winrt::fire_and_forget MainWindow::NewPickSingleFile_Click(winrt::Windows::Foundation::IInspectable const&, RoutedEventArgs const&)
+ {
+ auto lifetime = get_strong();
+
+ try
+ {
+ FileOpenPicker picker{ this->AppWindow().Id() };
+
+ if (IsChecked(CommitButtonCheckBox()))
+ {
+ picker.CommitButtonText(CommitButtonTextInput().Text());
+ }
+
+ if (IsChecked(ViewModeCheckBox()))
+ {
+ picker.ViewMode(GetSelectedNewViewMode());
+ }
+
+ if (IsChecked(SuggestedStartLocationCheckBox()))
+ {
+ picker.SuggestedStartLocation(GetSelectedNewLocationId());
+ }
+
+ if (IsChecked(FileTypeFilterCheckBox()))
+ {
+ for (auto const& filter : GetFileFilters())
+ {
+ picker.FileTypeFilter().Append(filter);
+ }
+ }
+
+ auto result = co_await picker.PickSingleFileAsync();
+ if (result)
+ {
+ std::wstring path{ result.Path().c_str() };
+ std::wstring fileName = FileNameFromPath(path);
+
+ std::wstringstream message;
+ message << L"New FileOpenPicker - PickSingleFileAsync:\nFile: " << fileName << L"\nPath: " << path;
+ LogResult(winrt::hstring{ message.str() });
+ }
+ else
+ {
+ LogResult(L"New FileOpenPicker - PickSingleFileAsync: Operation cancelled");
+ }
+ }
+ catch (winrt::hresult_error const& ex)
+ {
+ std::wstring message = L"Error in New FileOpenPicker: ";
+ message.append(ex.message().c_str());
+ LogResult(winrt::hstring{ message });
+ }
+
+ co_return;
+ }
+
+ winrt::fire_and_forget MainWindow::NewPickMultipleFiles_Click(winrt::Windows::Foundation::IInspectable const&, RoutedEventArgs const&)
+ {
+ auto lifetime = get_strong();
+
+ try
+ {
+ FileOpenPicker picker{ this->AppWindow().Id() };
+
+ if (IsChecked(CommitButtonCheckBox()))
+ {
+ picker.CommitButtonText(CommitButtonTextInput().Text());
+ }
+
+ if (IsChecked(ViewModeCheckBox()))
+ {
+ picker.ViewMode(GetSelectedNewViewMode());
+ }
+
+ if (IsChecked(SuggestedStartLocationCheckBox()))
+ {
+ picker.SuggestedStartLocation(GetSelectedNewLocationId());
+ }
+
+ if (IsChecked(FileTypeFilterCheckBox()))
+ {
+ for (auto const& filter : GetFileFilters())
+ {
+ picker.FileTypeFilter().Append(filter);
+ }
+ }
+
+ auto results = co_await picker.PickMultipleFilesAsync();
+ if (results && results.Size() > 0)
+ {
+ std::wstringstream message;
+ message << L"New FileOpenPicker - PickMultipleFilesAsync: " << results.Size() << L" files\n";
+
+ for (auto const& item : results)
+ {
+ std::wstring path{ item.Path().c_str() };
+ message << L"- " << FileNameFromPath(path) << L": " << path << L"\n";
+ }
+
+ LogResult(winrt::hstring{ message.str() });
+ }
+ else
+ {
+ LogResult(L"New FileOpenPicker - PickMultipleFilesAsync: Operation cancelled or no files selected");
+ }
+ }
+ catch (winrt::hresult_error const& ex)
+ {
+ std::wstring message = L"Error in New PickMultipleFilesAsync: ";
+ message.append(ex.message().c_str());
+ LogResult(winrt::hstring{ message });
+ }
+
+ co_return;
+ }
+
+ winrt::fire_and_forget MainWindow::NewPickSaveFile_Click(winrt::Windows::Foundation::IInspectable const&, RoutedEventArgs const&)
+ {
+ auto lifetime = get_strong();
+
+ try
+ {
+ FileSavePicker picker{ this->AppWindow().Id() };
+
+ if (IsChecked(SuggestedFileNameCheckBox()))
+ {
+ picker.SuggestedFileName(SuggestedFileNameInput().Text());
+ }
+
+ if (IsChecked(DefaultFileExtensionCheckBox()))
+ {
+ picker.DefaultFileExtension(DefaultFileExtensionInput().Text());
+ }
+
+ if (IsChecked(SuggestedFolderCheckBox()))
+ {
+ auto folder = TrimString(SuggestedFolderInput().Text().c_str());
+ if (!folder.empty())
+ {
+ picker.SuggestedFolder(winrt::hstring{ folder });
+ }
+ }
+
+ if (IsChecked(FileTypeChoicesCheckBox()))
+ {
+ auto jsonText = TrimString(FileTypeChoicesInput().Text().c_str());
+ if (!jsonText.empty())
+ {
+ JsonObject jsonObject;
+ if (JsonObject::TryParse(jsonText, jsonObject))
+ {
+ for (auto const& kvp : jsonObject)
+ {
+ std::vector values;
+ if (kvp.Value().ValueType() == JsonValueType::Array)
+ {
+ for (auto const& value : kvp.Value().GetArray())
+ {
+ if (value.ValueType() == JsonValueType::String)
+ {
+ values.emplace_back(value.GetString());
+ }
+ }
+ }
+
+ if (!values.empty())
+ {
+ picker.FileTypeChoices().Insert(kvp.Key(), winrt::single_threaded_vector(std::move(values)));
+ }
+ }
+ }
+ else
+ {
+ LogResult(L"Error in New FileSavePicker: Unable to parse FileTypeChoices JSON");
+ }
+ }
+ }
+
+ if (IsChecked(CommitButtonCheckBox()))
+ {
+ picker.CommitButtonText(CommitButtonTextInput().Text());
+ }
+
+ if (IsChecked(SuggestedStartLocationCheckBox()))
+ {
+ picker.SuggestedStartLocation(GetSelectedNewLocationId());
+ }
+
+ auto result = co_await picker.PickSaveFileAsync();
+ if (result)
+ {
+ std::wstring path{ result.Path().c_str() };
+ std::wstring fileName = FileNameFromPath(path);
+
+ std::wstringstream message;
+ message << L"New FileSavePicker picked file: \n" << fileName << L"\nPath: " << path;
+ LogResult(winrt::hstring{ message.str() });
+ }
+ else
+ {
+ LogResult(L"New FileSavePicker with FileTypeChoices\nOperation cancelled");
+ }
+ }
+ catch (winrt::hresult_error const& ex)
+ {
+ std::wstring message = L"Error in New FileTypeChoices: ";
+ message.append(ex.message().c_str());
+ LogResult(winrt::hstring{ message });
+ }
+
+ co_return;
+ }
+
+ winrt::fire_and_forget MainWindow::NewPickFolder_Click(winrt::Windows::Foundation::IInspectable const&, RoutedEventArgs const&)
+ {
+ auto lifetime = get_strong();
+
+ try
+ {
+ FolderPicker picker{ this->AppWindow().Id() };
+
+ if (IsChecked(CommitButtonCheckBox()))
+ {
+ picker.CommitButtonText(CommitButtonTextInput().Text());
+ }
+
+ if (IsChecked(SuggestedStartLocationCheckBox()))
+ {
+ picker.SuggestedStartLocation(GetSelectedNewLocationId());
+ }
+
+ auto result = co_await picker.PickSingleFolderAsync();
+ if (result)
+ {
+ std::wstring path{ result.Path().c_str() };
+ std::wstring folderName = FileNameFromPath(path);
+
+ std::wstringstream message;
+ message << L"New FolderPicker - PickSingleFolderAsync:\nFolder: " << folderName << L"\nPath: " << path;
+ LogResult(winrt::hstring{ message.str() });
+ }
+ else
+ {
+ LogResult(L"New FolderPicker - PickSingleFolderAsync: Operation cancelled");
+ }
+ }
+ catch (winrt::hresult_error const& ex)
+ {
+ std::wstring message = L"Error in New FolderPicker: ";
+ message.append(ex.message().c_str());
+ LogResult(winrt::hstring{ message });
+ }
+
+ co_return;
+ }
+}
diff --git a/Samples/StoragePickers/cpp-sample/MainWindow.xaml.h b/Samples/StoragePickers/cpp-sample/MainWindow.xaml.h
new file mode 100644
index 000000000..11ea6c41c
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/MainWindow.xaml.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include "MainWindow.g.h"
+
+#include
+
+namespace winrt::FilePickersAppSinglePackaged::implementation
+{
+ struct MainWindow : MainWindowT
+ {
+ MainWindow();
+
+ winrt::fire_and_forget NewPickSingleFile_Click(winrt::Windows::Foundation::IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
+ winrt::fire_and_forget NewPickMultipleFiles_Click(winrt::Windows::Foundation::IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
+ winrt::fire_and_forget NewPickSaveFile_Click(winrt::Windows::Foundation::IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
+ winrt::fire_and_forget NewPickFolder_Click(winrt::Windows::Foundation::IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
+
+ private:
+ void LogResult(winrt::hstring const& message);
+ Microsoft::Windows::Storage::Pickers::PickerLocationId GetSelectedNewLocationId();
+ Microsoft::Windows::Storage::Pickers::PickerViewMode GetSelectedNewViewMode();
+ std::vector GetFileFilters();
+ };
+}
+
+namespace winrt::FilePickersAppSinglePackaged::factory_implementation
+{
+ struct MainWindow : MainWindowT
+ {
+ };
+}
diff --git a/Samples/StoragePickers/cpp-sample/Package.appxmanifest b/Samples/StoragePickers/cpp-sample/Package.appxmanifest
new file mode 100644
index 000000000..40858e125
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/Package.appxmanifest
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+ FilePickersAppSinglePackaged
+ xiaomgao
+ Assets\StoreLogo.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/StoragePickers/cpp-sample/app.manifest b/Samples/StoragePickers/cpp-sample/app.manifest
new file mode 100644
index 000000000..f56549697
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/app.manifest
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PerMonitorV2
+
+
+
\ No newline at end of file
diff --git a/Samples/StoragePickers/cpp-sample/packages.config b/Samples/StoragePickers/cpp-sample/packages.config
new file mode 100644
index 000000000..5ad1c12a7
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/packages.config
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Samples/StoragePickers/cpp-sample/pch.cpp b/Samples/StoragePickers/cpp-sample/pch.cpp
new file mode 100644
index 000000000..1d9f38c57
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/pch.cpp
@@ -0,0 +1 @@
+#include "pch.h"
diff --git a/Samples/StoragePickers/cpp-sample/pch.h b/Samples/StoragePickers/cpp-sample/pch.h
new file mode 100644
index 000000000..294c200b5
--- /dev/null
+++ b/Samples/StoragePickers/cpp-sample/pch.h
@@ -0,0 +1,27 @@
+#pragma once
+#include
+#include
+#include
+#include
+
+// Undefine GetCurrentTime macro to prevent
+// conflict with Storyboard::GetCurrentTime
+#undef GetCurrentTime
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
\ No newline at end of file
diff --git a/Samples/StoragePickers/cs-sample/App.xaml b/Samples/StoragePickers/cs-sample/App.xaml
new file mode 100644
index 000000000..5a11fec41
--- /dev/null
+++ b/Samples/StoragePickers/cs-sample/App.xaml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/StoragePickers/cs-sample/App.xaml.cs b/Samples/StoragePickers/cs-sample/App.xaml.cs
new file mode 100644
index 000000000..2411ed5df
--- /dev/null
+++ b/Samples/StoragePickers/cs-sample/App.xaml.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Controls.Primitives;
+using Microsoft.UI.Xaml.Data;
+using Microsoft.UI.Xaml.Input;
+using Microsoft.UI.Xaml.Media;
+using Microsoft.UI.Xaml.Navigation;
+using Microsoft.UI.Xaml.Shapes;
+using Windows.ApplicationModel;
+using Windows.ApplicationModel.Activation;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+
+// To learn more about WinUI, the WinUI project structure,
+// and more about our project templates, see: http://aka.ms/winui-project-info.
+
+namespace FilePickersAppSinglePackaged
+{
+ ///
+ /// Provides application-specific behavior to supplement the default Application class.
+ ///
+ public partial class App : Application
+ {
+ private Window? _window;
+
+ ///
+ /// Initializes the singleton application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ ///
+ public App()
+ {
+ InitializeComponent();
+ }
+
+ ///
+ /// Invoked when the application is launched.
+ ///
+ /// Details about the launch request and process.
+ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
+ {
+ _window = new MainWindow();
+ _window.Activate();
+ }
+ }
+}
diff --git a/Samples/StoragePickers/cs-sample/Assets/LockScreenLogo.scale-200.png b/Samples/StoragePickers/cs-sample/Assets/LockScreenLogo.scale-200.png
new file mode 100644
index 000000000..7440f0d4b
Binary files /dev/null and b/Samples/StoragePickers/cs-sample/Assets/LockScreenLogo.scale-200.png differ
diff --git a/Samples/StoragePickers/cs-sample/Assets/SplashScreen.scale-200.png b/Samples/StoragePickers/cs-sample/Assets/SplashScreen.scale-200.png
new file mode 100644
index 000000000..32f486a86
Binary files /dev/null and b/Samples/StoragePickers/cs-sample/Assets/SplashScreen.scale-200.png differ
diff --git a/Samples/StoragePickers/cs-sample/Assets/Square150x150Logo.scale-200.png b/Samples/StoragePickers/cs-sample/Assets/Square150x150Logo.scale-200.png
new file mode 100644
index 000000000..53ee3777e
Binary files /dev/null and b/Samples/StoragePickers/cs-sample/Assets/Square150x150Logo.scale-200.png differ
diff --git a/Samples/StoragePickers/cs-sample/Assets/Square44x44Logo.scale-200.png b/Samples/StoragePickers/cs-sample/Assets/Square44x44Logo.scale-200.png
new file mode 100644
index 000000000..f713bba67
Binary files /dev/null and b/Samples/StoragePickers/cs-sample/Assets/Square44x44Logo.scale-200.png differ
diff --git a/Samples/StoragePickers/cs-sample/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/Samples/StoragePickers/cs-sample/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
new file mode 100644
index 000000000..dc9f5bea0
Binary files /dev/null and b/Samples/StoragePickers/cs-sample/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ
diff --git a/Samples/StoragePickers/cs-sample/Assets/StoreLogo.png b/Samples/StoragePickers/cs-sample/Assets/StoreLogo.png
new file mode 100644
index 000000000..a4586f26b
Binary files /dev/null and b/Samples/StoragePickers/cs-sample/Assets/StoreLogo.png differ
diff --git a/Samples/StoragePickers/cs-sample/Assets/Wide310x150Logo.scale-200.png b/Samples/StoragePickers/cs-sample/Assets/Wide310x150Logo.scale-200.png
new file mode 100644
index 000000000..8b4a5d0dd
Binary files /dev/null and b/Samples/StoragePickers/cs-sample/Assets/Wide310x150Logo.scale-200.png differ
diff --git a/Samples/StoragePickers/cs-sample/FilePickersAppSinglePackaged.csproj b/Samples/StoragePickers/cs-sample/FilePickersAppSinglePackaged.csproj
new file mode 100644
index 000000000..c987cb7ca
--- /dev/null
+++ b/Samples/StoragePickers/cs-sample/FilePickersAppSinglePackaged.csproj
@@ -0,0 +1,72 @@
+
+
+ WinExe
+ net8.0-windows10.0.19041.0
+ 10.0.17763.0
+ FilePickersAppSinglePackaged
+ app.manifest
+ x86;x64;ARM64
+ win-x86;win-x64;win-arm64
+ win-$(Platform).pubxml
+ true
+ true
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+ False
+ True
+ False
+ True
+ False
+ True
+ FilePickersAppSinglePackaged_TemporaryKey.pfx
+ SHA256
+ True
+ True
+ Never
+ 0
+
+
\ No newline at end of file
diff --git a/Samples/StoragePickers/cs-sample/FilePickersAppSinglePackaged.sln b/Samples/StoragePickers/cs-sample/FilePickersAppSinglePackaged.sln
new file mode 100644
index 000000000..6082d3de0
--- /dev/null
+++ b/Samples/StoragePickers/cs-sample/FilePickersAppSinglePackaged.sln
@@ -0,0 +1,43 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.14.36401.2 d17.14
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FilePickersAppSinglePackaged", "FilePickersAppSinglePackaged.csproj", "{EF931EC9-5781-40C7-8395-8B7FE01E146D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|ARM64 = Debug|ARM64
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|ARM64 = Release|ARM64
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Debug|ARM64.Build.0 = Debug|ARM64
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Debug|ARM64.Deploy.0 = Debug|ARM64
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Debug|x64.ActiveCfg = Debug|x64
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Debug|x64.Build.0 = Debug|x64
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Debug|x64.Deploy.0 = Debug|x64
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Debug|x86.ActiveCfg = Debug|x86
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Debug|x86.Build.0 = Debug|x86
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Debug|x86.Deploy.0 = Debug|x86
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Release|ARM64.ActiveCfg = Release|ARM64
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Release|ARM64.Build.0 = Release|ARM64
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Release|ARM64.Deploy.0 = Release|ARM64
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Release|x64.ActiveCfg = Release|x64
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Release|x64.Build.0 = Release|x64
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Release|x64.Deploy.0 = Release|x64
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Release|x86.ActiveCfg = Release|x86
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Release|x86.Build.0 = Release|x86
+ {EF931EC9-5781-40C7-8395-8B7FE01E146D}.Release|x86.Deploy.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {635ACFB4-9E53-4940-82CC-B3A3314A4FCD}
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/StoragePickers/cs-sample/MainWindow.xaml b/Samples/StoragePickers/cs-sample/MainWindow.xaml
new file mode 100644
index 000000000..4ea5482cf
--- /dev/null
+++ b/Samples/StoragePickers/cs-sample/MainWindow.xaml
@@ -0,0 +1,180 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/StoragePickers/cs-sample/MainWindow.xaml.cs b/Samples/StoragePickers/cs-sample/MainWindow.xaml.cs
new file mode 100644
index 000000000..9aaf39839
--- /dev/null
+++ b/Samples/StoragePickers/cs-sample/MainWindow.xaml.cs
@@ -0,0 +1,299 @@
+using Microsoft.UI.Xaml;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using System.Text;
+using System.Text.Json.Serialization;
+
+// To learn more about WinUI, the WinUI project structure,
+// and more about our project templates, see: http://aka.ms/winui-project-info.
+
+namespace FilePickersAppSinglePackaged
+{
+
+ [JsonSerializable(typeof(Dictionary>))]
+ internal partial class SourceGenerationContext : JsonSerializerContext
+ {
+ }
+
+ public sealed partial class MainWindow : Window
+ {
+ public MainWindow()
+ {
+ this.InitializeComponent();
+ Title = "File Pickers Sample App";
+
+ // Set window size to make it taller
+ this.AppWindow.Resize(new Windows.Graphics.SizeInt32(1800, 1100));
+ }
+
+ #region Helper Methods
+
+ private void LogResult(string message)
+ {
+ ResultsTextBlock.Text = $"[{DateTime.Now:HH:mm:ss}] {message}\n{ResultsTextBlock.Text}";
+ }
+
+ private Microsoft.Windows.Storage.Pickers.PickerLocationId GetSelectedNewLocationId()
+ {
+ switch (StartLocationComboBox.SelectedIndex)
+ {
+ case 0: return Microsoft.Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
+ case 1: return Microsoft.Windows.Storage.Pickers.PickerLocationId.ComputerFolder;
+ case 2: return Microsoft.Windows.Storage.Pickers.PickerLocationId.Desktop;
+ case 3: return Microsoft.Windows.Storage.Pickers.PickerLocationId.Downloads;
+
+ // HomeGroup is excluded from the new PickerLocationId enum. This example demonstrates how the error would look like.
+ case 4: return (Microsoft.Windows.Storage.Pickers.PickerLocationId)4;
+
+ case 5: return Microsoft.Windows.Storage.Pickers.PickerLocationId.MusicLibrary;
+ case 6: return Microsoft.Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
+ case 7: return Microsoft.Windows.Storage.Pickers.PickerLocationId.VideosLibrary;
+ case 8: return Microsoft.Windows.Storage.Pickers.PickerLocationId.Objects3D;
+ case 9: return Microsoft.Windows.Storage.Pickers.PickerLocationId.Unspecified;
+ case 10: return (Microsoft.Windows.Storage.Pickers.PickerLocationId)10;
+ default: throw new InvalidOperationException("Invalid location selected");
+ }
+ }
+
+ private Microsoft.Windows.Storage.Pickers.PickerViewMode GetSelectedNewViewMode()
+ {
+ switch (ViewModeComboBox.SelectedIndex)
+ {
+ case 0: return Microsoft.Windows.Storage.Pickers.PickerViewMode.List;
+ case 1: return Microsoft.Windows.Storage.Pickers.PickerViewMode.Thumbnail;
+ case 2: return (Microsoft.Windows.Storage.Pickers.PickerViewMode)2;
+ default: throw new InvalidOperationException("Invalid view mode selected");
+ }
+ }
+
+ private string[] GetFileFilters()
+ {
+ string input = FileTypeFilterInput.Text?.Trim() ?? "";
+ if (string.IsNullOrEmpty(input))
+ return ["*"];
+
+ return input.Split([','], StringSplitOptions.RemoveEmptyEntries)
+ .Select(s => s.Trim())
+ .ToArray();
+ }
+
+ #endregion
+
+ #region FileOpenPicker Tests
+
+ private async void NewPickSingleFile_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ // Initialize new picker with AppWindow.Id
+ // for console apps, use the `default` as app window id, for instance:
+ // var picker = new Microsoft.Windows.Storage.Pickers.FileOpenPicker(default);
+ var picker = new Microsoft.Windows.Storage.Pickers.FileOpenPicker(this.AppWindow.Id);
+
+ if (CommitButtonCheckBox.IsChecked == true)
+ {
+ picker.CommitButtonText = CommitButtonTextInput.Text;
+ }
+
+ if (ViewModeCheckBox.IsChecked == true)
+ {
+ picker.ViewMode = GetSelectedNewViewMode();
+ }
+
+ if (SuggestedStartLocationCheckBox.IsChecked == true)
+ {
+ picker.SuggestedStartLocation = GetSelectedNewLocationId();
+ }
+
+ if (FileTypeFilterCheckBox.IsChecked == true)
+ {
+ foreach (var filter in GetFileFilters())
+ {
+ picker.FileTypeFilter.Add(filter);
+ }
+ }
+
+ var result = await picker.PickSingleFileAsync();
+ if (result != null)
+ {
+ LogResult($"New FileOpenPicker - PickSingleFileAsync:\nFile: {System.IO.Path.GetFileName(result.Path)}\nPath: {result.Path}");
+ }
+ else
+ {
+ LogResult("New FileOpenPicker - PickSingleFileAsync: Operation cancelled");
+ }
+ }
+ catch (Exception ex)
+ {
+ LogResult($"Error in New FileOpenPicker: {ex.Message}");
+ }
+ }
+
+ private async void NewPickMultipleFiles_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ // Initialize new picker with AppWindow.Id
+ // for console apps, use the `default` as app window id, for instance:
+ // var picker = new Microsoft.Windows.Storage.Pickers.FileOpenPicker(default);
+ var picker = new Microsoft.Windows.Storage.Pickers.FileOpenPicker(this.AppWindow.Id);
+
+ if (CommitButtonCheckBox.IsChecked == true)
+ {
+ picker.CommitButtonText = CommitButtonTextInput.Text;
+ }
+
+ if (ViewModeCheckBox.IsChecked == true)
+ {
+ picker.ViewMode = GetSelectedNewViewMode();
+ }
+
+ if (SuggestedStartLocationCheckBox.IsChecked == true)
+ {
+ picker.SuggestedStartLocation = GetSelectedNewLocationId();
+ }
+
+ if (FileTypeFilterCheckBox.IsChecked == true)
+ {
+ foreach (var filter in GetFileFilters())
+ {
+ picker.FileTypeFilter.Add(filter);
+ }
+ }
+
+ var results = await picker.PickMultipleFilesAsync();
+ if (results != null && results.Count > 0)
+ {
+ var sb = new StringBuilder($"New FileOpenPicker - PickMultipleFilesAsync: {results.Count} files\n");
+ foreach (var result in results)
+ {
+ sb.AppendLine($"- {System.IO.Path.GetFileName(result.Path)}: {result.Path}");
+ }
+ LogResult(sb.ToString());
+ }
+ else
+ {
+ LogResult("New FileOpenPicker - PickMultipleFilesAsync: Operation cancelled or no files selected");
+ }
+ }
+ catch (Exception ex)
+ {
+ LogResult($"Error in New PickMultipleFilesAsync: {ex.Message}");
+ }
+ }
+
+ #endregion
+
+ #region FileSavePicker Tests
+
+ private async void NewPickSaveFile_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ // Initialize new picker with AppWindow.Id
+ // for console apps, use the `default` as app window id, for instance:
+ // var picker = new Microsoft.Windows.Storage.Pickers.FileSavePicker(default);
+ var picker = new Microsoft.Windows.Storage.Pickers.FileSavePicker(this.AppWindow.Id);
+
+ if (SuggestedFileNameCheckBox.IsChecked == true)
+ {
+ picker.SuggestedFileName = SuggestedFileNameInput.Text;
+ }
+
+ if (DefaultFileExtensionCheckBox.IsChecked == true)
+ {
+ picker.DefaultFileExtension = DefaultFileExtensionInput.Text;
+ }
+
+ if (SuggestedFolderCheckBox.IsChecked == true)
+ {
+ picker.SuggestedFolder = SuggestedFolderInput.Text;
+ }
+
+ if (FileTypeChoicesCheckBox.IsChecked == true)
+ {
+ var choicesJson = (string)FileTypeChoicesInput.Text;
+ if (!string.IsNullOrEmpty(choicesJson))
+ {
+ var choices = System.Text.Json.JsonSerializer.Deserialize(choicesJson, SourceGenerationContext.Default.DictionaryStringListString);
+ if (choices != null)
+ {
+ foreach (var choice in choices)
+ {
+ picker.FileTypeChoices.Add(choice.Key, choice.Value);
+ }
+ }
+ }
+ }
+
+ if (CommitButtonCheckBox.IsChecked == true)
+ {
+ picker.CommitButtonText = CommitButtonTextInput.Text;
+ }
+
+ if (SuggestedStartLocationCheckBox.IsChecked == true)
+ {
+ picker.SuggestedStartLocation = GetSelectedNewLocationId();
+ }
+
+ var result = await picker.PickSaveFileAsync();
+ if (result != null)
+ {
+ LogResult($"New FileSavePicker picked file: \n{System.IO.Path.GetFileName(result.Path)}\nPath: {result.Path}");
+ }
+ else
+ {
+ LogResult("New FileSavePicker with FileTypeChoices\nOperation cancelled");
+ }
+ }
+ catch (Exception ex)
+ {
+ LogResult($"Error in New FileTypeChoices: {ex.Message}");
+ }
+ }
+
+ #endregion
+
+ #region FolderPicker Tests
+
+ private async void NewPickFolder_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ // Initialize new picker with AppWindow.Id
+ // for console apps, use the `default` as app window id, for instance:
+ // var picker = new Microsoft.Windows.Storage.Pickers.FolderPicker(default);
+ var picker = new Microsoft.Windows.Storage.Pickers.FolderPicker(this.AppWindow.Id);
+
+ if (CommitButtonCheckBox.IsChecked == true)
+ {
+ picker.CommitButtonText = CommitButtonTextInput.Text;
+ }
+
+ if (SuggestedStartLocationCheckBox.IsChecked == true)
+ {
+ picker.SuggestedStartLocation = GetSelectedNewLocationId();
+ }
+
+ var result = await picker.PickSingleFolderAsync();
+ if (result != null)
+ {
+ LogResult($"New FolderPicker - PickSingleFolderAsync:\nFolder: {System.IO.Path.GetFileName(result.Path)}\nPath: {result.Path}");
+ }
+ else
+ {
+ LogResult("New FolderPicker - PickSingleFolderAsync: Operation cancelled");
+ }
+ }
+ catch (Exception ex)
+ {
+ LogResult($"Error in New FolderPicker: {ex.Message}");
+ }
+ }
+
+ #endregion
+ }
+
+}
diff --git a/Samples/StoragePickers/cs-sample/Package.appxmanifest b/Samples/StoragePickers/cs-sample/Package.appxmanifest
new file mode 100644
index 000000000..501de98c9
--- /dev/null
+++ b/Samples/StoragePickers/cs-sample/Package.appxmanifest
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+ FilePickersAppSinglePackaged
+ xiaomgao
+ Assets\StoreLogo.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Samples/StoragePickers/cs-sample/Properties/PublishProfiles/FolderProfile.pubxml b/Samples/StoragePickers/cs-sample/Properties/PublishProfiles/FolderProfile.pubxml
new file mode 100644
index 000000000..ca2c25558
--- /dev/null
+++ b/Samples/StoragePickers/cs-sample/Properties/PublishProfiles/FolderProfile.pubxml
@@ -0,0 +1,11 @@
+
+
+
+
+ Release
+ ARM64
+ bin\\\win-x64\publish\win-x64\
+ FileSystem
+ <_TargetId>Folder
+
+
\ No newline at end of file
diff --git a/Samples/StoragePickers/cs-sample/Properties/PublishProfiles/win-arm64.pubxml b/Samples/StoragePickers/cs-sample/Properties/PublishProfiles/win-arm64.pubxml
new file mode 100644
index 000000000..f361bfe8f
--- /dev/null
+++ b/Samples/StoragePickers/cs-sample/Properties/PublishProfiles/win-arm64.pubxml
@@ -0,0 +1,18 @@
+
+
+
+
+ FileSystem
+ ARM64
+ win-arm64
+ bin\\\win-arm64\publish\win-arm64\
+ true
+ false
+ Release
+ net8.0-windows10.0.19041.0
+ false
+ false
+
+
\ No newline at end of file
diff --git a/Samples/StoragePickers/cs-sample/Properties/PublishProfiles/win-x64.pubxml b/Samples/StoragePickers/cs-sample/Properties/PublishProfiles/win-x64.pubxml
new file mode 100644
index 000000000..e3e688695
--- /dev/null
+++ b/Samples/StoragePickers/cs-sample/Properties/PublishProfiles/win-x64.pubxml
@@ -0,0 +1,18 @@
+
+
+
+
+ FileSystem
+ x64
+ win-x64
+ bin\\\win-x64\publish\
+ true
+ false
+ Release
+ net8.0-windows10.0.19041.0
+ false
+ false
+
+
\ No newline at end of file
diff --git a/Samples/StoragePickers/cs-sample/Properties/PublishProfiles/win-x86.pubxml b/Samples/StoragePickers/cs-sample/Properties/PublishProfiles/win-x86.pubxml
new file mode 100644
index 000000000..a70c69425
--- /dev/null
+++ b/Samples/StoragePickers/cs-sample/Properties/PublishProfiles/win-x86.pubxml
@@ -0,0 +1,14 @@
+
+
+
+
+ FileSystem
+ x86
+ win-x86
+ bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\
+ true
+ False
+
+
\ No newline at end of file
diff --git a/Samples/StoragePickers/cs-sample/Properties/launchSettings.json b/Samples/StoragePickers/cs-sample/Properties/launchSettings.json
new file mode 100644
index 000000000..e0c0ad43a
--- /dev/null
+++ b/Samples/StoragePickers/cs-sample/Properties/launchSettings.json
@@ -0,0 +1,10 @@
+{
+ "profiles": {
+ "FilePickersAppSinglePackaged (Package)": {
+ "commandName": "MsixPackage"
+ },
+ "FilePickersAppSinglePackaged (Unpackaged)": {
+ "commandName": "Project"
+ }
+ }
+}
\ No newline at end of file
diff --git a/Samples/StoragePickers/cs-sample/app.manifest b/Samples/StoragePickers/cs-sample/app.manifest
new file mode 100644
index 000000000..f56549697
--- /dev/null
+++ b/Samples/StoragePickers/cs-sample/app.manifest
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PerMonitorV2
+
+
+
\ No newline at end of file
diff --git a/Samples/StoragePickers/images/deploy1.png b/Samples/StoragePickers/images/deploy1.png
new file mode 100644
index 000000000..8a6367c1a
Binary files /dev/null and b/Samples/StoragePickers/images/deploy1.png differ
diff --git a/Samples/StoragePickers/images/deploy10.png b/Samples/StoragePickers/images/deploy10.png
new file mode 100644
index 000000000..0bd1c3169
Binary files /dev/null and b/Samples/StoragePickers/images/deploy10.png differ
diff --git a/Samples/StoragePickers/images/deploy2.png b/Samples/StoragePickers/images/deploy2.png
new file mode 100644
index 000000000..927df22ef
Binary files /dev/null and b/Samples/StoragePickers/images/deploy2.png differ
diff --git a/Samples/StoragePickers/images/deploy3.png b/Samples/StoragePickers/images/deploy3.png
new file mode 100644
index 000000000..c25e7e927
Binary files /dev/null and b/Samples/StoragePickers/images/deploy3.png differ
diff --git a/Samples/StoragePickers/images/deploy4.png b/Samples/StoragePickers/images/deploy4.png
new file mode 100644
index 000000000..2ce2b4950
Binary files /dev/null and b/Samples/StoragePickers/images/deploy4.png differ
diff --git a/Samples/StoragePickers/images/deploy5.png b/Samples/StoragePickers/images/deploy5.png
new file mode 100644
index 000000000..6072709d0
Binary files /dev/null and b/Samples/StoragePickers/images/deploy5.png differ
diff --git a/Samples/StoragePickers/images/deploy6.png b/Samples/StoragePickers/images/deploy6.png
new file mode 100644
index 000000000..8f6315cf8
Binary files /dev/null and b/Samples/StoragePickers/images/deploy6.png differ
diff --git a/Samples/StoragePickers/images/deploy7.png b/Samples/StoragePickers/images/deploy7.png
new file mode 100644
index 000000000..3cd0ffc7f
Binary files /dev/null and b/Samples/StoragePickers/images/deploy7.png differ
diff --git a/Samples/StoragePickers/images/deploy8.png b/Samples/StoragePickers/images/deploy8.png
new file mode 100644
index 000000000..bd735be89
Binary files /dev/null and b/Samples/StoragePickers/images/deploy8.png differ
diff --git a/Samples/StoragePickers/images/deploy9.png b/Samples/StoragePickers/images/deploy9.png
new file mode 100644
index 000000000..97832ba63
Binary files /dev/null and b/Samples/StoragePickers/images/deploy9.png differ
diff --git a/Samples/StoragePickers/images/screenshot-storage-pickers.png b/Samples/StoragePickers/images/screenshot-storage-pickers.png
new file mode 100644
index 000000000..f123907f2
Binary files /dev/null and b/Samples/StoragePickers/images/screenshot-storage-pickers.png differ