Skip to content

Commit dd78334

Browse files
authored
Initial WinUI2 GetStart project (#172)
* Initial WinUI2 GetStart project * Change publisher
1 parent e39308c commit dd78334

19 files changed

+500
-0
lines changed

GettingStartedGuides/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
<!-- only enough info to differentiate this dir level vs the others; what is different about this dir compared to the sibling dirs? -->
44
These are completed Visual Studio projects that result from following the steps in the [Getting Started tutorials](https://learn.microsoft.com/microsoft-edge/webview2/get-started/get-started).
5+
6+
These are baseline WebView2 projects with a few lines of WebView2 starter code to embed and use the WebView2 control. You can use one of these projects as a starting point to add additional WebView2 code.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.4.33122.133
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyUWPGetStartApp", "MyUWPGetStartApp\MyUWPGetStartApp.csproj", "{084E5E38-2616-4B38-964F-53D16E0F83C9}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|ARM = Debug|ARM
11+
Debug|ARM64 = Debug|ARM64
12+
Debug|x64 = Debug|x64
13+
Debug|x86 = Debug|x86
14+
Release|ARM = Release|ARM
15+
Release|ARM64 = Release|ARM64
16+
Release|x64 = Release|x64
17+
Release|x86 = Release|x86
18+
EndGlobalSection
19+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Debug|ARM.ActiveCfg = Debug|ARM
21+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Debug|ARM.Build.0 = Debug|ARM
22+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Debug|ARM.Deploy.0 = Debug|ARM
23+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Debug|ARM64.ActiveCfg = Debug|ARM64
24+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Debug|ARM64.Build.0 = Debug|ARM64
25+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Debug|ARM64.Deploy.0 = Debug|ARM64
26+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Debug|x64.ActiveCfg = Debug|x64
27+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Debug|x64.Build.0 = Debug|x64
28+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Debug|x64.Deploy.0 = Debug|x64
29+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Debug|x86.ActiveCfg = Debug|x86
30+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Debug|x86.Build.0 = Debug|x86
31+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Debug|x86.Deploy.0 = Debug|x86
32+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Release|ARM.ActiveCfg = Release|ARM
33+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Release|ARM.Build.0 = Release|ARM
34+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Release|ARM.Deploy.0 = Release|ARM
35+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Release|ARM64.ActiveCfg = Release|ARM64
36+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Release|ARM64.Build.0 = Release|ARM64
37+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Release|ARM64.Deploy.0 = Release|ARM64
38+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Release|x64.ActiveCfg = Release|x64
39+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Release|x64.Build.0 = Release|x64
40+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Release|x64.Deploy.0 = Release|x64
41+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Release|x86.ActiveCfg = Release|x86
42+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Release|x86.Build.0 = Release|x86
43+
{084E5E38-2616-4B38-964F-53D16E0F83C9}.Release|x86.Deploy.0 = Release|x86
44+
EndGlobalSection
45+
GlobalSection(SolutionProperties) = preSolution
46+
HideSolutionNode = FALSE
47+
EndGlobalSection
48+
GlobalSection(ExtensibilityGlobals) = postSolution
49+
SolutionGuid = {3471BCDB-1792-4F87-A58A-EB77219A9098}
50+
EndGlobalSection
51+
EndGlobal
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Application
2+
x:Class="MyUWPGetStartApp.App"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:MyUWPGetStartApp">
6+
7+
</Application>
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.InteropServices.WindowsRuntime;
6+
using Windows.ApplicationModel;
7+
using Windows.ApplicationModel.Activation;
8+
using Windows.Foundation;
9+
using Windows.Foundation.Collections;
10+
using Windows.UI.Xaml;
11+
using Windows.UI.Xaml.Controls;
12+
using Windows.UI.Xaml.Controls.Primitives;
13+
using Windows.UI.Xaml.Data;
14+
using Windows.UI.Xaml.Input;
15+
using Windows.UI.Xaml.Media;
16+
using Windows.UI.Xaml.Navigation;
17+
18+
namespace MyUWPGetStartApp
19+
{
20+
/// <summary>
21+
/// Provides application-specific behavior to supplement the default Application class.
22+
/// </summary>
23+
sealed partial class App : Application
24+
{
25+
/// <summary>
26+
/// Initializes the singleton application object. This is the first line of authored code
27+
/// executed, and as such is the logical equivalent of main() or WinMain().
28+
/// </summary>
29+
public App()
30+
{
31+
this.InitializeComponent();
32+
this.Suspending += OnSuspending;
33+
}
34+
35+
/// <summary>
36+
/// Invoked when the application is launched normally by the end user. Other entry points
37+
/// will be used such as when the application is launched to open a specific file.
38+
/// </summary>
39+
/// <param name="e">Details about the launch request and process.</param>
40+
protected override void OnLaunched(LaunchActivatedEventArgs e)
41+
{
42+
Frame rootFrame = Window.Current.Content as Frame;
43+
44+
// Do not repeat app initialization when the Window already has content,
45+
// just ensure that the window is active
46+
if (rootFrame == null)
47+
{
48+
// Create a Frame to act as the navigation context and navigate to the first page
49+
rootFrame = new Frame();
50+
51+
rootFrame.NavigationFailed += OnNavigationFailed;
52+
53+
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
54+
{
55+
//TODO: Load state from previously suspended application
56+
}
57+
58+
// Place the frame in the current Window
59+
Window.Current.Content = rootFrame;
60+
}
61+
62+
if (e.PrelaunchActivated == false)
63+
{
64+
if (rootFrame.Content == null)
65+
{
66+
// When the navigation stack isn't restored navigate to the first page,
67+
// configuring the new page by passing required information as a navigation
68+
// parameter
69+
rootFrame.Navigate(typeof(MainPage), e.Arguments);
70+
}
71+
// Ensure the current window is active
72+
Window.Current.Activate();
73+
}
74+
}
75+
76+
/// <summary>
77+
/// Invoked when Navigation to a certain page fails
78+
/// </summary>
79+
/// <param name="sender">The Frame which failed navigation</param>
80+
/// <param name="e">Details about the navigation failure</param>
81+
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
82+
{
83+
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
84+
}
85+
86+
/// <summary>
87+
/// Invoked when application execution is being suspended. Application state is saved
88+
/// without knowing whether the application will be terminated or resumed with the contents
89+
/// of memory still intact.
90+
/// </summary>
91+
/// <param name="sender">The source of the suspend request.</param>
92+
/// <param name="e">Details about the suspend request.</param>
93+
private void OnSuspending(object sender, SuspendingEventArgs e)
94+
{
95+
var deferral = e.SuspendingOperation.GetDeferral();
96+
//TODO: Save application state and stop any background activity
97+
deferral.Complete();
98+
}
99+
}
100+
}
1.4 KB
Loading
7.52 KB
Loading
2.87 KB
Loading
1.61 KB
Loading
Loading
1.42 KB
Loading

0 commit comments

Comments
 (0)