From 8532634d619f220c723cad9c63da7131af98d25a Mon Sep 17 00:00:00 2001 From: Nic Champagne Williamson Date: Tue, 19 Nov 2024 16:35:47 -0800 Subject: [PATCH] Add simple sample app for WV2CC --- .../WebView2WpfCompositionControl/README.md | 29 ++++++ .../WebView2WpfCompositionControl.sln | 25 +++++ .../WebView2WpfCompositionControl/App.xaml | 9 ++ .../WebView2WpfCompositionControl/App.xaml.cs | 14 +++ .../AssemblyInfo.cs | 10 ++ .../MainWindow.xaml | 60 +++++++++++ .../MainWindow.xaml.cs | 95 ++++++++++++++++++ .../WebView2WpfCompositionControl.csproj | 17 ++++ .../screenshot.png | Bin 0 -> 818511 bytes 9 files changed, 259 insertions(+) create mode 100644 SampleApps/WebView2WpfCompositionControl/README.md create mode 100644 SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl.sln create mode 100644 SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/App.xaml create mode 100644 SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/App.xaml.cs create mode 100644 SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/AssemblyInfo.cs create mode 100644 SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/MainWindow.xaml create mode 100644 SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/MainWindow.xaml.cs create mode 100644 SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/WebView2WpfCompositionControl.csproj create mode 100644 SampleApps/WebView2WpfCompositionControl/screenshot.png diff --git a/SampleApps/WebView2WpfCompositionControl/README.md b/SampleApps/WebView2WpfCompositionControl/README.md new file mode 100644 index 0000000..06259d9 --- /dev/null +++ b/SampleApps/WebView2WpfCompositionControl/README.md @@ -0,0 +1,29 @@ +--- +description: "Demonstrates the features and usage patterns of WebView2CompositionControl in a WPF app." +extendedZipContent: + - + path: SharedContent + target: SharedContent + - + path: LICENSE + target: LICENSE +languages: + - cpp +page_type: sample +products: + - microsoft-edge +--- +# WebView2WpfCompositionControl sample app + + + + +This sample, **WebView2WpfCompositionControl**, embeds a WPF WebView2CompositionControl within a .NET Core 3.0 and/or .NET 8 WPF application. The WebView2CompositionControl solves the WPF "Airspace" issue (where all WPF content showed up below the WebView2 in the regular WPF control) by using D3D11 graphics capture session to show and interact with WebView2 content in a regular WPF WebView2 control. In general, the WebView2CompositionControl can be used as a stand-in replacement for the regular WPF WebView2 control. + + +This sample is built as a WPF .NET Core application in Visual Studio 2022. + + +This is the main WebView2 sample. The running **WebView2APISample** app window shows the WebView2 SDK version and also the WebView2 Runtime version and path. The **WebView2APISample** app has several menus containing many menuitems that demonstrate a broad range of WebView2 APIs: + +![The WebView2WpfCompositionControl sample app running](./documentation/screenshot.png) \ No newline at end of file diff --git a/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl.sln b/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl.sln new file mode 100644 index 0000000..fa132af --- /dev/null +++ b/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35431.28 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebView2WpfCompositionControl", "WebView2WpfCompositionControl\WebView2WpfCompositionControl.csproj", "{B4C22133-B97C-4593-AB64-BE1694A0EC21}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B4C22133-B97C-4593-AB64-BE1694A0EC21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B4C22133-B97C-4593-AB64-BE1694A0EC21}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B4C22133-B97C-4593-AB64-BE1694A0EC21}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B4C22133-B97C-4593-AB64-BE1694A0EC21}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0E35B434-5EE7-4941-835D-0E7BD2B4D824} + EndGlobalSection +EndGlobal diff --git a/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/App.xaml b/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/App.xaml new file mode 100644 index 0000000..f2982f8 --- /dev/null +++ b/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/App.xaml.cs b/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/App.xaml.cs new file mode 100644 index 0000000..67575bf --- /dev/null +++ b/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/App.xaml.cs @@ -0,0 +1,14 @@ +using System.Configuration; +using System.Data; +using System.Windows; + +namespace WebView2WpfCompositionControl +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } + +} diff --git a/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/AssemblyInfo.cs b/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/AssemblyInfo.cs new file mode 100644 index 0000000..372e037 --- /dev/null +++ b/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/MainWindow.xaml b/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/MainWindow.xaml new file mode 100644 index 0000000..0e6a563 --- /dev/null +++ b/SampleApps/WebView2WpfCompositionControl/WebView2WpfCompositionControl/MainWindow.xaml @@ -0,0 +1,60 @@ + + + + + + + + + + + +