-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from egvijayanand/working
Embedded project updated to .NET 9 Preview 7
- Loading branch information
Showing
13 changed files
with
86 additions
and
90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
"sdk": { | ||
"allowPrerelease": true, | ||
"rollForward": "latestMinor", | ||
"version": "7.0.100" | ||
"version": "8.0.100" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"sdk": { | ||
"allowPrerelease": true, | ||
"rollForward": "latestMinor", | ||
"version": "8.0.100" | ||
} | ||
|
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 |
---|---|---|
@@ -1,30 +1,26 @@ | ||
namespace EmbeddedWindows | ||
namespace EmbeddedWindows; | ||
|
||
/// <summary> | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
private Window? m_window; | ||
|
||
/// <summary> | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// 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 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(); | ||
} | ||
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) | ||
{ | ||
m_window = new MainWindow(); | ||
m_window?.Activate(); | ||
} | ||
|
||
private Window? m_window; | ||
/// <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) | ||
{ | ||
m_window = new MainWindow(); | ||
m_window?.Activate(); | ||
} | ||
} |
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
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
5 changes: 1 addition & 4 deletions
5
src/NET_9/EmbeddedWindows/EmbeddedWindows/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
54 changes: 32 additions & 22 deletions
54
src/NET_9/EmbeddedWindows/EmbeddedWindows/Views/MainWindow.xaml.cs
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 |
---|---|---|
@@ -1,31 +1,41 @@ | ||
using Microsoft.Maui.Hosting; | ||
using Microsoft.Maui.Platform; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Embedding; | ||
using Microsoft.Extensions.DependencyInjection; | ||
// Note: There's a change in namespace. | ||
using Microsoft.Maui.Controls.Embedding; | ||
//using Microsoft.Maui.Embedding; | ||
|
||
namespace EmbeddedWindows | ||
namespace EmbeddedWindows; | ||
|
||
/// <summary> | ||
/// An empty window that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
public sealed partial class MainWindow : Window | ||
{ | ||
/// <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() | ||
{ | ||
public MainWindow() | ||
{ | ||
this.InitializeComponent(); | ||
this.InitializeComponent(); | ||
|
||
var mauiApp = MauiApp.CreateBuilder() | ||
.UseMauiEmbeddedApp<MyApp>() // Note: The method name too got updated. | ||
.ConfigureFonts(fonts => | ||
{ | ||
fonts.AddFont("OpenSans-Regular.ttf", "OS400"); | ||
fonts.AddFont("OpenSans-SemiBold.ttf", "OS600"); | ||
}) | ||
.Build(); | ||
|
||
// 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<IApplication>(); | ||
|
||
var mauiContext = new MauiContext(mauiApp.Services); | ||
|
||
var mauiApp = MauiApp.CreateBuilder() | ||
.UseMauiEmbedding<MyApp>() | ||
.ConfigureFonts(fonts => | ||
{ | ||
fonts.AddFont("OpenSans-Regular.ttf", "OS400"); | ||
fonts.AddFont("OpenSans-SemiBold.ttf", "OS600"); | ||
}) | ||
.Build(); | ||
// While doing .NET MAUI Embedding, this call is required so that the Application object instance gets resolved. | ||
var _ = mauiApp.Services.GetRequiredService<IApplication>(); | ||
Content = new MauiPage().ToPlatform(new MauiContext(mauiApp.Services)); | ||
} | ||
// Platform-neutral - Windowless API | ||
Content = new MauiPage().ToPlatform(mauiContext); | ||
// Updated Window inclusive API | ||
Content = new MauiPage().ToPlatformEmbedded(mauiContext); | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,10 +1,6 @@ | ||
namespace MauiLib | ||
namespace MauiLib; | ||
|
||
public partial class MauiPage : ContentPage | ||
{ | ||
public partial class MauiPage : ContentPage | ||
{ | ||
public MauiPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
public MauiPage() => InitializeComponent(); | ||
} |
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 |
---|---|---|
@@ -1,10 +1,6 @@ | ||
namespace MauiLib | ||
namespace MauiLib; | ||
|
||
public partial class MyApp : Application | ||
{ | ||
public partial class MyApp : Application | ||
{ | ||
public MyApp() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
public MyApp() => InitializeComponent(); | ||
} |