Skip to content

Commit 1709010

Browse files
authored
WinUI 3 sample: Update Readme and fixed-version Runtime code (#258)
* Update readme & cmtd-out Runtime code * in-sentence link * official name of sample
1 parent d480172 commit 1709010

File tree

3 files changed

+13
-54
lines changed

3 files changed

+13
-54
lines changed

SampleApps/WebView2_WinUI3_Sample/WebView2_WinUI3_Sample/App.xaml.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ public App()
2222
{
2323
this.InitializeComponent();
2424

25-
// If your shipping a fixed version WebView2 SDK with your application you will need
26-
// to use the following code (update the runtime version to what your shipping.
27-
28-
//StorageFolder localFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
29-
//String fixedPath = Path.Combine(localFolder.Path, "FixedRuntime\\95.0.1020.53");
30-
//Debug.WriteLine($"Launch path [{localFolder.Path}]");
31-
//Debug.WriteLine($"FixedRuntime path [{fixedPath}]");
32-
//Environment.SetEnvironmentVariable("WEBVIEW2_BROWSER_EXECUTABLE_FOLDER", fixedPath);
25+
// If you're shipping a fixed-version WebView2 Runtime with your app, un-comment the
26+
// following lines of code, and change the version number to the version number of the
27+
// WebView2 Runtime that you're packaging and shipping to users:
3328

29+
// StorageFolder localFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
30+
// String fixedPath = Path.Combine(localFolder.Path, "FixedRuntime\\130.0.2849.39");
31+
// Debug.WriteLine($"Launch path [{localFolder.Path}]");
32+
// Debug.WriteLine($"FixedRuntime path [{fixedPath}]");
33+
// Environment.SetEnvironmentVariable("WEBVIEW2_BROWSER_EXECUTABLE_FOLDER", fixedPath);
3434
}
3535

3636
/// <summary>
Loading
+5-46
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,9 @@
1-
# Introduction
2-
This sample shows off using a WebView2 control in a WinUi 3 Windows SDK Packaged application.
3-
4-
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.
5-
6-
# Relevant directories
7-
8-
| Directory | Contents |
9-
--- | --- |
10-
| WebView2_WinUI3_Sample | Project code |
11-
| WebView2_WinUI3_Sample (Package) | Packaging and distribution project |
12-
| WebView2_WinUI3_Sample (Package)\FixedRuntime | (Optional) Fixed WebView2 runtime |
13-
| WebView2_WinUI3_Sample (Package)\FixedRuntime\95.0.1020.53 | (Optional) Fixed WebView2 runtime sample |
14-
15-
16-
# Fixed version usage
17-
If you want to ship a fixed version of the WebView2 runtime with your application you will need to include it in your project.
18-
19-
Instructions can be found at: https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution
20-
21-
The following assume you are using runtime version 95.0.1020.53, you will change this number to whatever version you are using.
22-
23-
You will need to:
24-
1 Include the fixed WebView2 runtime in the package project
25-
<pre>\WebView2_WinUI3_Sample\WebView2_WinUI3_Sample (Package)\FixedRuntime\95.0.1020.53\</pre>
26-
2 Update the package project wapproj file for the version your using
27-
<pre> < Content Include="FixedRuntime\95.0.1020.53\\**\*.*" > </pre>
28-
3 Uncomment the code in app.xaml.cs to enable the runtime override
29-
<pre>
30-
public App()
31-
{
32-
this.InitializeComponent();
33-
// If you are shipping a fixed version WebView2 SDK with your application you will need
34-
// to use the following code (update the runtime version to what you are shipping.
35-
StorageFolder localFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
36-
String fixedPath = Path.Combine(localFolder.Path, "FixedRuntime\\95.0.1020.53");
37-
Debug.WriteLine($"Launch path [{localFolder.Path}]");
38-
Debug.WriteLine($"FixedRuntime path [{fixedPath}]");
39-
Environment.SetEnvironmentVariable("WEBVIEW2_BROWSER_EXECUTABLE_FOLDER", fixedPath);
40-
}
41-
</pre>
42-
4 Update the version information for the appropriate version
43-
<pre>
44-
String fixedPath = Path.Combine(localFolder.Path, "FixedRuntime\\95.0.1020.53");
45-
</pre>
46-
1+
# WinUI 3 (Windows App SDK) sample app
472

3+
This sample (**WebView2_WinUI3_Sample**) demonstrates using a WebView2 control in a WinUI 3 (Windows App SDK) Packaged application.
484

5+
![Sample app](./images/sample-app.png)
496

7+
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.
508

9+
To use this sample, see [WinUI 3 (Windows App SDK) sample app](https://learn.microsoft.com/microsoft-edge/webview2/samples/webview2-winui3-sample).

0 commit comments

Comments
 (0)