Skip to content

Commit

Permalink
Native embedding in .NET 9. (#2571)
Browse files Browse the repository at this point in the history
* Initial doc versioning.

* Add link.

* Fix link.

* Version section.

* .NET 9 edits.

* Edits.

* Edit.

* Edits.

* Edits.

* Edits for clarity.

* Edits.

* Edit.

* Edits.

* Edits.

* Edits.

* Edits.

* Edits.
  • Loading branch information
davidbritch authored Oct 18, 2024
1 parent ff9cde1 commit 3351cb8
Show file tree
Hide file tree
Showing 3 changed files with 661 additions and 15 deletions.
17 changes: 17 additions & 0 deletions docs/platform-integration/includes/static-mauiapp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
ms.topic: include
ms.date: 17/10/2024
---

> [!TIP]
> Creating a <xref:Microsoft.Maui.Hosting.MauiApp> object each time a .NET MAUI view is embedded as a native view isn't recommended. This can be problematic if embedded views access the `Application.Current` property. Instead, the <xref:Microsoft.Maui.Hosting.MauiApp> object can be created as a shared, static instance:
>
> ```csharp
> public static class MyEmbeddedMauiApp
> {
> static MauiApp? _shared;
> public static MauiApp Shared => _shared ??= MauiProgram.CreateMauiApp();
> }
> ```
>
> With this approach, you can instantiate the <xref:Microsoft.Maui.Hosting.MauiApp> object early in your app lifecycle to avoid having a small delay the first time you embed a .NET MAUI view in your app.
Loading

0 comments on commit 3351cb8

Please sign in to comment.