-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WinUI 3 native embedding of BlazorWebView sample
- Loading branch information
1 parent
43ea32b
commit 8fceb1d
Showing
49 changed files
with
1,430 additions
and
7 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
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
Binary file not shown.
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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// To learn more about WinUI, the WinUI project structure, | ||
// and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
||
namespace HybridRclApp.WinUI | ||
{ | ||
/// <summary> | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
/// <summary> | ||
/// Initializes the singleton application object. This is the first line of authored code | ||
/// executed, and as such is the logical equivalent of main() or WinMain(). | ||
/// </summary> | ||
public App() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
/// <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. | ||
/// </summary> | ||
/// <param name="args">Details about the launch request and process.</param> | ||
protected override void OnLaunched(LaunchActivatedEventArgs args) | ||
{ | ||
new MainWindow().Activate(); | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
src/HybridRclApp/HybridRclApp.WinUI/HybridRclApp.WinUI.csproj
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework> | ||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion> | ||
<OutputType>WinExe</OutputType> | ||
|
||
<!-- .NET MAUI --> | ||
<UseMaui>true</UseMaui> | ||
<SingleProject>true</SingleProject> | ||
<EnableDefaultCssItems>false</EnableDefaultCssItems> | ||
|
||
<!-- Uncomment the below property if intended to run the project as Unpackaged --> | ||
<!--<WindowsPackageType>None</WindowsPackageType>--> | ||
|
||
<!-- Display name --> | ||
<ApplicationTitle>HybridRclApp</ApplicationTitle> | ||
|
||
<!-- App Identifier --> | ||
<ApplicationIdGuid>7d3b675d-62d4-427d-a35d-bcf4194ec2a9</ApplicationIdGuid> | ||
|
||
<!-- Versions --> | ||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> | ||
<ApplicationVersion>1</ApplicationVersion> | ||
|
||
<!-- WinUI 3 --> | ||
<UseWinUI>true</UseWinUI> | ||
<EnableMsixTooling>true</EnableMsixTooling> | ||
|
||
<!-- Project Options --> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>latest</LangVersion> | ||
<!--<ImplicitUsings>enable</ImplicitUsings>--> | ||
<RootNamespace>HybridRclApp.WinUI</RootNamespace> | ||
|
||
<!-- App Options --> | ||
<Platforms>x86;x64;arm64</Platforms> | ||
<ApplicationManifest>app.manifest</ApplicationManifest> | ||
<PublishProfile>win10-$(Platform).pubxml</PublishProfile> | ||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<!-- App Icon --> | ||
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4"/> | ||
<!-- Splash Screen --> | ||
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" BaseSize="128,128"/> | ||
<!-- Images --> | ||
<MauiImage Include="Resources\Images\*"/> | ||
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" /> | ||
<!-- Custom Fonts --> | ||
<MauiFont Include="Resources\Fonts\*"/> | ||
<!-- Raw Assets (also remove the "Resources\Raw" prefix) --> | ||
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="VijayAnand.MauiBlazor.Markup" Version="3.0.0-preview.*" /> | ||
<Manifest Include="$(ApplicationManifest)" /> | ||
</ItemGroup> | ||
|
||
<!-- | ||
Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging | ||
Tools extension to be activated for this project even if the Windows App SDK Nuget | ||
package has not yet been restored. | ||
--> | ||
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'"> | ||
<ProjectCapability Include="Msix" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\HybridRclApp.RazorLib\HybridRclApp.RazorLib.csproj" /> | ||
</ItemGroup> | ||
|
||
<!-- | ||
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution | ||
Explorer "Package and Publish" context menu entry to be enabled for this project even if | ||
the Windows App SDK Nuget package has not yet been restored. | ||
--> | ||
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'"> | ||
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu> | ||
</PropertyGroup> | ||
</Project> |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
global using Microsoft.UI.Xaml; | ||
global using Microsoft.UI.Xaml.Controls; | ||
|
||
global using HybridRclApp.RazorLib.Data; | ||
global using HybridRclApp.RazorLib.Pages; | ||
global using HybridRclApp.RazorLib.Shared; |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Router AppAssembly="@GetType().Assembly" AdditionalAssemblies="new[] { typeof(Counter).Assembly }"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> | ||
</Found> | ||
<NotFound> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p>Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// To learn more about WinUI, the WinUI project structure, | ||
// and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
||
using Microsoft.AspNetCore.Components.WebView.Maui; | ||
using VijayAnand.MauiBlazor.Markup; | ||
using Microsoft.Maui.Platform; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Maui; | ||
using static Microsoft.Maui.Dispatching.Dispatcher; | ||
|
||
namespace HybridRclApp.WinUI | ||
{ | ||
/// <summary> | ||
/// An empty window that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
public sealed partial class MainWindow : Window | ||
{ | ||
public MainWindow() | ||
{ | ||
var services = new ServiceCollection(); | ||
services.AddSingleton(GetForCurrentThread()!); | ||
services.AddMauiBlazorWebView(); | ||
services.AddSingleton<WeatherForecastService>(); | ||
#if DEBUG | ||
services.AddBlazorWebViewDeveloperTools(); | ||
#endif | ||
|
||
Content = new Grid() | ||
{ | ||
Children = | ||
{ | ||
new BlazorWebView().Configure("wwwroot/index.html", "/counter", ("#app", typeof(Main), null)) | ||
.ToPlatform(new MauiContext(services.BuildServiceProvider())) | ||
} | ||
}; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<Package | ||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" | ||
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 Publisher="CN=User Name" /> | ||
|
||
<Properties> | ||
<PublisherDisplayName>User Name</PublisherDisplayName> | ||
</Properties> | ||
|
||
<Dependencies> | ||
<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> | ||
<Resource Language="x-generate"/> | ||
</Resources> | ||
|
||
<Applications> | ||
<Application Id="App" | ||
Executable="$targetnametoken$.exe" | ||
EntryPoint="$targetentrypoint$"> | ||
<uap:VisualElements /> | ||
</Application> | ||
</Applications> | ||
|
||
<Capabilities> | ||
<rescap:Capability Name="runFullTrust" /> | ||
</Capabilities> | ||
</Package> |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
namespace HybridRclApp.WinUI | ||
{ | ||
#if !DISABLE_XAML_GENERATED_MAIN | ||
/// <summary> | ||
/// Program class | ||
/// </summary> | ||
public static class Program | ||
{ | ||
[global::System.Runtime.InteropServices.DllImport("Microsoft.ui.xaml.dll")] | ||
private static extern void XamlCheckProcessRequirements(); | ||
|
||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.UI.Xaml.Markup.Compiler"," 1.0.0.0")] | ||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] | ||
[global::System.STAThreadAttribute] | ||
static void Main(string[] args) | ||
{ | ||
XamlCheckProcessRequirements(); | ||
|
||
global::WinRT.ComWrappersSupport.InitializeComWrappers(); | ||
global::Microsoft.UI.Xaml.Application.Start((p) => { | ||
var context = new global::Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext(global::Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread()); | ||
global::System.Threading.SynchronizationContext.SetSynchronizationContext(context); | ||
new App(); | ||
}); | ||
} | ||
} | ||
#endif | ||
|
||
partial class App : global::Microsoft.UI.Xaml.Application | ||
{ | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.UI.Xaml.Markup.Compiler"," 1.0.0.0")] | ||
private bool _contentLoaded; | ||
/// <summary> | ||
/// InitializeComponent() | ||
/// </summary> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.UI.Xaml.Markup.Compiler"," 1.0.0.0")] | ||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] | ||
public void InitializeComponent() | ||
{ | ||
if (_contentLoaded) | ||
return; | ||
|
||
_contentLoaded = true; | ||
|
||
global::System.Uri resourceLocator = new global::System.Uri("ms-appx:///App.xaml"); | ||
global::Microsoft.UI.Xaml.Application.LoadComponent(this, resourceLocator); | ||
|
||
#if DEBUG && !DISABLE_XAML_GENERATED_BINDING_DEBUG_OUTPUT | ||
DebugSettings.BindingFailed += (sender, args) => | ||
{ | ||
global::System.Diagnostics.Debug.WriteLine(args.Message); | ||
}; | ||
#endif | ||
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION | ||
UnhandledException += (sender, e) => | ||
{ | ||
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break(); | ||
}; | ||
#endif | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/HybridRclApp/HybridRclApp.WinUI/Properties/PublishProfiles/win10-arm64.pubxml
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?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>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> | ||
<!-- | ||
See https://github.com/microsoft/CsWinRT/issues/373 | ||
<PublishTrimmed>True</PublishTrimmed> | ||
--> | ||
</PropertyGroup> | ||
</Project> |
20 changes: 20 additions & 0 deletions
20
src/HybridRclApp/HybridRclApp.WinUI/Properties/PublishProfiles/win10-x64.pubxml
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?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>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> | ||
<!-- | ||
See https://github.com/microsoft/CsWinRT/issues/373 | ||
<PublishTrimmed>True</PublishTrimmed> | ||
--> | ||
</PropertyGroup> | ||
</Project> |
20 changes: 20 additions & 0 deletions
20
src/HybridRclApp/HybridRclApp.WinUI/Properties/PublishProfiles/win10-x86.pubxml
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?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>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> | ||
<!-- | ||
See https://github.com/microsoft/CsWinRT/issues/373 | ||
<PublishTrimmed>True</PublishTrimmed> | ||
--> | ||
</PropertyGroup> | ||
</Project> |
10 changes: 10 additions & 0 deletions
10
src/HybridRclApp/HybridRclApp.WinUI/Properties/launchSettings.json
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"profiles": { | ||
"HybridRclApp.WinUI (Package)": { | ||
"commandName": "MsixPackage" | ||
}, | ||
"HybridRclApp.WinUI (Unpackaged)": { | ||
"commandName": "Project" | ||
} | ||
} | ||
} |
Binary file added
BIN
+105 KB
src/HybridRclApp/HybridRclApp.WinUI/Resources/Fonts/OpenSans-Regular.ttf
Binary file not shown.
Binary file added
BIN
+108 KB
src/HybridRclApp/HybridRclApp.WinUI/Resources/Fonts/OpenSans-SemiBold.ttf
Binary file not shown.
Oops, something went wrong.