forked from MicrosoftEdge/WebView2Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from MicrosoftEdge/main
WinUI 3 sample: Update Readme and fixed-version Runtime code (MicrosoftEdge#258)
- Loading branch information
Showing
3 changed files
with
13 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,9 @@ | ||
# Introduction | ||
This sample shows off using a WebView2 control in a WinUi 3 Windows SDK Packaged application. | ||
|
||
It also optionaly shows how you would update the application to ship with a fixed WebView2 version instead of using the version installed and running on the Windows computer. | ||
|
||
# Relevant directories | ||
|
||
| Directory | Contents | | ||
--- | --- | | ||
| WebView2_WinUI3_Sample | Project code | | ||
| WebView2_WinUI3_Sample (Package) | Packaging and distribution project | | ||
| WebView2_WinUI3_Sample (Package)\FixedRuntime | (Optional) Fixed WebView2 runtime | | ||
| WebView2_WinUI3_Sample (Package)\FixedRuntime\95.0.1020.53 | (Optional) Fixed WebView2 runtime sample | | ||
|
||
|
||
# Fixed version usage | ||
If you want to ship a fixed version of the WebView2 runtime with your application you will need to include it in your project. | ||
|
||
Instructions can be found at: https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution | ||
|
||
The following assume you are using runtime version 95.0.1020.53, you will change this number to whatever version you are using. | ||
|
||
You will need to: | ||
1 Include the fixed WebView2 runtime in the package project | ||
<pre>\WebView2_WinUI3_Sample\WebView2_WinUI3_Sample (Package)\FixedRuntime\95.0.1020.53\</pre> | ||
2 Update the package project wapproj file for the version your using | ||
<pre> < Content Include="FixedRuntime\95.0.1020.53\\**\*.*" > </pre> | ||
3 Uncomment the code in app.xaml.cs to enable the runtime override | ||
<pre> | ||
public App() | ||
{ | ||
this.InitializeComponent(); | ||
// If you are shipping a fixed version WebView2 SDK with your application you will need | ||
// to use the following code (update the runtime version to what you are shipping. | ||
StorageFolder localFolder = Windows.ApplicationModel.Package.Current.InstalledLocation; | ||
String fixedPath = Path.Combine(localFolder.Path, "FixedRuntime\\95.0.1020.53"); | ||
Debug.WriteLine($"Launch path [{localFolder.Path}]"); | ||
Debug.WriteLine($"FixedRuntime path [{fixedPath}]"); | ||
Environment.SetEnvironmentVariable("WEBVIEW2_BROWSER_EXECUTABLE_FOLDER", fixedPath); | ||
} | ||
</pre> | ||
4 Update the version information for the appropriate version | ||
<pre> | ||
String fixedPath = Path.Combine(localFolder.Path, "FixedRuntime\\95.0.1020.53"); | ||
</pre> | ||
|
||
# WinUI 3 (Windows App SDK) sample app | ||
|
||
This sample (**WebView2_WinUI3_Sample**) demonstrates using a WebView2 control in a WinUI 3 (Windows App SDK) Packaged application. | ||
|
||
![Sample app](./images/sample-app.png) | ||
|
||
This sample also allows you to ship the app with a fixed-version WebView2 Runtime, instead of using whichever version of the WebView2 Runtime is installed and running on the user's computer. | ||
|
||
To use this sample, see [WinUI 3 (Windows App SDK) sample app](https://learn.microsoft.com/microsoft-edge/webview2/samples/webview2-winui3-sample). |