From 99f6fcafe0a1d18ec1d480f7c63071bf366dbfbc Mon Sep 17 00:00:00 2001
From: Vijay Anand E G <81947404+egvijayanand@users.noreply.github.com>
Date: Wed, 4 Sep 2024 15:03:54 +0530
Subject: [PATCH] MapsApp Embedded project updated to .NET 9 Preview 7
---
README.md | 4 +++-
.../EmbeddedWindows/Views/MainWindow.xaml.cs | 2 +-
src/NET_9/MapsApp/MapsApp.csproj | 18 +++++++++------
.../{win10-arm64.pubxml => win-arm64.pubxml} | 11 +++++-----
.../{win10-x64.pubxml => win-x64.pubxml} | 9 ++++----
.../{win10-x86.pubxml => win-x86.pubxml} | 9 ++++----
src/NET_9/MapsApp/Views/MainWindow.xaml.cs | 22 ++++++++++++++-----
7 files changed, 45 insertions(+), 30 deletions(-)
rename src/NET_9/MapsApp/Properties/PublishProfiles/{win10-arm64.pubxml => win-arm64.pubxml} (58%)
rename src/NET_9/MapsApp/Properties/PublishProfiles/{win10-x64.pubxml => win-x64.pubxml} (61%)
rename src/NET_9/MapsApp/Properties/PublishProfiles/{win10-x86.pubxml => win-x86.pubxml} (61%)
diff --git a/README.md b/README.md
index eb70d29..88cd3c9 100644
--- a/README.md
+++ b/README.md
@@ -30,8 +30,10 @@ Made available in the `src\NET_9\` directory:
|Solution Title|Description|
|:---:|:---|
+|`EmbeddedAndroid`|.NET MAUI Page embedded in a .NET 9 for Android App, targeting .NET 9
Refer to this [article](https://egvijayanand.in/2024/02/29/dotnet-maui-native-embedding/) for working with this sample|
+|`EmbeddediOS`|.NET MAUI Page embedded in a .NET 9 for iOS App, targeting .NET 9
Refer to this [article](https://egvijayanand.in/2024/02/29/dotnet-maui-native-embedding/) for working with this sample|
|`EmbeddedWindows`|.NET MAUI Page embedded in a Native WinUI 3 App, targeting .NET 9
Refer to this [article](https://egvijayanand.in/2024/02/29/dotnet-maui-native-embedding/) for working with this sample|
-|`MapsApp`|.NET MAUI Maps embedded in a Native WinUI 3 App, targeting .NET 9
Refer to this [article](https://egvijayanand.in/2024/03/07/dotnet-maui-community-toolkit-maps-in-winui-3-app/) for working with this sample|
+|`MapsApp`|Using .NET MAUI [CommunityToolkit.Maui.Maps](https://www.nuget.org/packages/CommunityToolkit.Maui.Maps) embedded in a Native WinUI 3 App, targeting .NET 9
Refer to this [article](https://egvijayanand.in/2024/03/07/dotnet-maui-community-toolkit-maps-in-winui-3-app/) for working with this sample|
|`HybridWebViewApp`|A sample .NET MAUI App showcasing the features of the new [HybridWebView](https://learn.microsoft.com/en-us/dotnet/maui/whats-new/dotnet-9?view=net-maui-9.0#hybridwebview) control.|
Made available in the the `src\` directory:
diff --git a/src/NET_9/EmbeddedWindows/EmbeddedWindows/Views/MainWindow.xaml.cs b/src/NET_9/EmbeddedWindows/EmbeddedWindows/Views/MainWindow.xaml.cs
index 6dbb536..4f515ff 100644
--- a/src/NET_9/EmbeddedWindows/EmbeddedWindows/Views/MainWindow.xaml.cs
+++ b/src/NET_9/EmbeddedWindows/EmbeddedWindows/Views/MainWindow.xaml.cs
@@ -35,7 +35,7 @@ public MainWindow()
// Platform-neutral - Windowless API
Content = new MauiPage().ToPlatform(mauiContext);
- // Updated Window inclusive API
+ // Updated Window-aware API
Content = new MauiPage().ToPlatformEmbedded(mauiContext);
}
}
diff --git a/src/NET_9/MapsApp/MapsApp.csproj b/src/NET_9/MapsApp/MapsApp.csproj
index f1ccda2..783f996 100644
--- a/src/NET_9/MapsApp/MapsApp.csproj
+++ b/src/NET_9/MapsApp/MapsApp.csproj
@@ -10,6 +10,10 @@
true
None
+
+ true
+
+
enable
@@ -20,8 +24,9 @@
true
x86;x64;arm64
app.manifest
- win10-$(Platform).pubxml
- win10-x86;win10-x64;win10-arm64
+ win-$(Platform).pubxml
+ win-x86;win-x64;win-arm64
+ win10-x86;win10-x64;win10-arm64
@@ -35,12 +40,11 @@
-
-
-
-
+
+
+
-
+
diff --git a/src/NET_9/MapsApp/Properties/PublishProfiles/win10-arm64.pubxml b/src/NET_9/MapsApp/Properties/PublishProfiles/win-arm64.pubxml
similarity index 58%
rename from src/NET_9/MapsApp/Properties/PublishProfiles/win10-arm64.pubxml
rename to src/NET_9/MapsApp/Properties/PublishProfiles/win-arm64.pubxml
index 6de21bb..3d93189 100644
--- a/src/NET_9/MapsApp/Properties/PublishProfiles/win10-arm64.pubxml
+++ b/src/NET_9/MapsApp/Properties/PublishProfiles/win-arm64.pubxml
@@ -5,16 +5,15 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
FileSystem
- arm64
- win10-arm64
+ ARM64
+ win-arm64
+ win10-arm64
bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\
true
False
False
True
-
+ False
+ True
\ No newline at end of file
diff --git a/src/NET_9/MapsApp/Properties/PublishProfiles/win10-x64.pubxml b/src/NET_9/MapsApp/Properties/PublishProfiles/win-x64.pubxml
similarity index 61%
rename from src/NET_9/MapsApp/Properties/PublishProfiles/win10-x64.pubxml
rename to src/NET_9/MapsApp/Properties/PublishProfiles/win-x64.pubxml
index ed11b9d..eea93de 100644
--- a/src/NET_9/MapsApp/Properties/PublishProfiles/win10-x64.pubxml
+++ b/src/NET_9/MapsApp/Properties/PublishProfiles/win-x64.pubxml
@@ -6,15 +6,14 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
FileSystem
x64
- win10-x64
+ win-x64
+ win10-x64
bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\
true
False
False
True
-
+ False
+ True
\ No newline at end of file
diff --git a/src/NET_9/MapsApp/Properties/PublishProfiles/win10-x86.pubxml b/src/NET_9/MapsApp/Properties/PublishProfiles/win-x86.pubxml
similarity index 61%
rename from src/NET_9/MapsApp/Properties/PublishProfiles/win10-x86.pubxml
rename to src/NET_9/MapsApp/Properties/PublishProfiles/win-x86.pubxml
index e908edd..7c8835b 100644
--- a/src/NET_9/MapsApp/Properties/PublishProfiles/win10-x86.pubxml
+++ b/src/NET_9/MapsApp/Properties/PublishProfiles/win-x86.pubxml
@@ -6,15 +6,14 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
FileSystem
x86
- win10-x86
+ win-x86
+ win10-x86
bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\
true
False
False
True
-
+ False
+ True
\ No newline at end of file
diff --git a/src/NET_9/MapsApp/Views/MainWindow.xaml.cs b/src/NET_9/MapsApp/Views/MainWindow.xaml.cs
index 0e8c277..ab4bb68 100644
--- a/src/NET_9/MapsApp/Views/MainWindow.xaml.cs
+++ b/src/NET_9/MapsApp/Views/MainWindow.xaml.cs
@@ -1,6 +1,8 @@
using Microsoft.Maui.Hosting;
using Microsoft.Maui;
-using Microsoft.Maui.Embedding;
+// Note: There's a change in namespace.
+using Microsoft.Maui.Controls.Embedding;
+//using Microsoft.Maui.Embedding;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Maui.Platform;
using MapsApp.Extensions;
@@ -17,12 +19,22 @@ public MainWindow()
this.InitializeComponent();
var mauiApp = MauiApp.CreateBuilder()
- .UseMauiEmbedding()
+ .UseMauiEmbeddedApp() // Note: The method name too got updated.
.UseMauiToolkitMaps("") // To generate a Bing Maps API Key, visit https://www.bingmapsportal.com/
.Build();
- // While doing .NET MAUI Embedding, this call is required so that the Application object instance gets resolved.
- var _ = mauiApp.Services.GetRequiredService();
- Content = new HomePage().ToPlatform(new MauiContext(mauiApp.Services));
+
+ // From .NET MAUI 9 Preview 7 onwards, the below method call is no longer required
+ // as the .NET MAUI Embedding process is revamped.
+ // While doing .NET MAUI Embedding, this call is required so that
+ // the Application object instance gets resolved.
+ //var _ = mauiApp.Services.GetRequiredService();
+
+ var mauiContext = new MauiContext(mauiApp.Services);
+
+ // Platform-neutral - Windowless API
+ Content = new HomePage().ToPlatform(mauiContext);
+ // Updated Window-aware API
+ //Content = new HomePage().ToPlatformEmbedded(mauiContext);
}
}
}