Skip to content

Commit

Permalink
Replace WinUI3GetStarted 2020 project by result of latest project tem…
Browse files Browse the repository at this point in the history
…plate (#257)

* Replace WinUI3 2020 project by result of latest

* revert urlFragment

* readme say updated date for Maint
  • Loading branch information
mikehoffms authored Nov 4, 2024
1 parent 6bf4af5 commit d480172
Show file tree
Hide file tree
Showing 43 changed files with 271 additions and 3,194 deletions.
6 changes: 4 additions & 2 deletions GettingStartedGuides/WinUI3_GettingStarted/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ urlFragment: WinUI3_GettingStarted
# Get started with WebView2 in WinUI 3 (Windows App SDK) apps

<!-- only enough info to differentiate this sample vs the others; what is different about this sample compared to the sibling samples? -->
This sample, **WinUI3_GettingStarted**, is the completed Visual Studio project that results from following the steps in the tutorial [Get started with WebView2 in WinUI 3 (Windows App SDK) apps](https://learn.microsoft.com/microsoft-edge/webview2/get-started/winui).
This sample, **WinUI3GetStarted**, is the completed Visual Studio project that results from following the steps in the tutorial [Get started with WebView2 in WinUI 3 (Windows App SDK) apps](https://learn.microsoft.com/microsoft-edge/webview2/get-started/winui).

![The running app from the finished WinUI 3 (Windows App SDK) tutorial](screenshots/getting-started-part-3.png)
![The running app from the finished WinUI 3 (Windows App SDK) tutorial](screenshots/finished-app.png)

Project updated Nov. 1, 2024.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinUI3GetStarted", "WinUI3GetStarted\WinUI3GetStarted.csproj", "{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}"
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
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Debug|ARM64.ActiveCfg = Debug|ARM64
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Debug|ARM64.Build.0 = Debug|ARM64
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Debug|ARM64.Deploy.0 = Debug|ARM64
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Debug|x64.ActiveCfg = Debug|x64
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Debug|x64.Build.0 = Debug|x64
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Debug|x64.Deploy.0 = Debug|x64
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Debug|x86.ActiveCfg = Debug|x86
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Debug|x86.Build.0 = Debug|x86
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Debug|x86.Deploy.0 = Debug|x86
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Release|ARM64.ActiveCfg = Release|ARM64
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Release|ARM64.Build.0 = Release|ARM64
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Release|ARM64.Deploy.0 = Release|ARM64
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Release|x64.ActiveCfg = Release|x64
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Release|x64.Build.0 = Release|x64
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Release|x64.Deploy.0 = Release|x64
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Release|x86.ActiveCfg = Release|x86
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Release|x86.Build.0 = Release|x86
{FBF1E5FC-C14D-4C2D-88D4-6B8B55821E52}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1334E548-2468-4E8F-84AF-B2B85C674856}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Application
x:Class="WinUI3GetStarted.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinUI3GetStarted">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
</ResourceDictionary.MergedDictionaries>
<!-- Other app resources here -->
</ResourceDictionary>
</Application.Resources>
</Application>
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
using System;
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 System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -7,17 +15,11 @@
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Threading;
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;

namespace WinUI_Sample
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace WinUI3GetStarted
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
Expand All @@ -31,12 +33,10 @@ public partial class App : Application
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
}

/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// Invoked when the application is launched.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
Expand All @@ -45,18 +45,6 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar
m_window.Activate();
}

/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
// Save application state and stop any background activity
}

private Window m_window;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Window
x:Class="WinUI3GetStarted.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinUI3GetStarted"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>

<TextBox Name="addressBar" Grid.Column="0"/>
<Button x:Name="myButton" Grid.Column="1" Click="myButton_Click">Go</Button>

<controls:WebView2 x:Name="MyWebView" Grid.Row="1" Grid.ColumnSpan="2"
Source="https://www.microsoft.com" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"/>
</Grid>
</Window>
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.Web.WebView2.Core;
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 ABI.Microsoft.UI.Private.Controls;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;

// The Blank Window item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace WinUI_Sample
namespace WinUI3GetStarted
{
/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
Expand All @@ -27,17 +28,9 @@ public MainWindow()
{
this.InitializeComponent();
MyWebView.NavigationStarting += EnsureHttps;
//MyWebView.WebMessageReceived += UpdateAddressBar;

}

private void UpdateAddressBar(WebView2 sender, WebView2WebMessageReceivedEventArgs args)
{
//String uri = args.Source;
//addressBar.Text = uri;
}

private void EnsureHttps(WebView2 sender, WebView2NavigationStartingEventArgs args)
private void EnsureHttps(WebView2 sender, CoreWebView2NavigationStartingEventArgs args)
{
String uri = args.Uri;
if (!uri.StartsWith("https://"))
Expand All @@ -51,21 +44,17 @@ private void EnsureHttps(WebView2 sender, WebView2NavigationStartingEventArgs ar
}
}


private void myButton_Click(object sender, RoutedEventArgs e)
private void myButton_Click(object sender, RoutedEventArgs e)
{
//myButton.Content = "Clicked";

try
{
Uri targetUri = new Uri(addressBar.Text);
MyWebView.Source = targetUri;
}
catch (FormatException ex)
{
// Bad address.
// Incorrect address entered.
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">

<Identity
Name="25f0d1c7-2470-49df-b58d-3c2650506b00"
Publisher="CN=jasteph"
Name="2f643296-f430-4d03-9877-c1d17530b600"
Publisher="CN=v-mihoffman"
Version="1.0.0.0" />

<mp:PhoneIdentity PhoneProductId="2f643296-f430-4d03-9877-c1d17530b600" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

<Properties>
<DisplayName>WinUI_Sample (Package)</DisplayName>
<PublisherDisplayName>jasteph</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
<DisplayName>WinUI3GetStarted</DisplayName>
<PublisherDisplayName>v-mihoffman</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>

<Resources>
Expand All @@ -31,19 +34,18 @@
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="WinUI_Sample (Package)"
Description="WinUI_Sample (Package)"
DisplayName="WinUI3GetStarted"
Description="WinUI3GetStarted"
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />
<uap:SplashScreen Image="Images\SplashScreen.png" />
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>

<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>ARM64</Platform>
<RuntimeIdentifier Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) >= 8">win-arm64</RuntimeIdentifier>
<RuntimeIdentifier Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &lt; 8">win10-arm64</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x64</Platform>
<RuntimeIdentifier Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) >= 8">win-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &lt; 8">win10-x64</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x86</Platform>
<RuntimeIdentifier Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) >= 8">win-x86</RuntimeIdentifier>
<RuntimeIdentifier Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &lt; 8">win10-x86</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"profiles": {
"WinUI3GetStarted (Package)": {
"commandName": "MsixPackage"
},
"WinUI3GetStarted (Unpackaged)": {
"commandName": "Project"
}
}
}
Loading

0 comments on commit d480172

Please sign in to comment.