Skip to content

Commit

Permalink
Merge pull request #1827 from unoplatform/mergify/bp/legacy/2x/pr-1816
Browse files Browse the repository at this point in the history
fix: Set Parent to be Window (backport #1816)
  • Loading branch information
nickrandolph authored Aug 29, 2023
2 parents 708a40b + 47d0a20 commit 30c52ba
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,15 @@ public partial class SyncfusionDemoPage : ContentPage
public SyncfusionDemoPage()
{
InitializeComponent();

Loaded += SyncfusionDemoPage_Loaded;
}

private void SyncfusionDemoPage_Loaded(object sender, EventArgs e)
{
var pv = Window?.Handler?.PlatformView;
var hpv = Handler?.PlatformView;

var current = DeviceDisplay.Current;
}
}
2 changes: 2 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<!-- Ensures the .xr.xml files are generated in a proper layout folder -->
<GenerateLibraryLayout>true</GenerateLibraryLayout>
<ImplicitUsings>true</ImplicitUsings>

<UnoExtensionsGeneration_DisableCreateNewOnMetadataUpdateAttribute>True</UnoExtensionsGeneration_DisableCreateNewOnMetadataUpdateAttribute>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
<Project>
<ItemGroup>
<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableKeyEqualityGenerator" />

<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableCompatibilityTypesGenerator" />
<!--System.Diagnostics.CodeAnalysis-->
<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableDynamicallyAccessedMembersAttribute" />
<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableMaybeNullAttribute" />
<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableMaybeNullWhenAttribute" />
<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableMemberNotNullWhenAttribute" />
<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableNotNullIfNotNullAttribute" />
<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableNotNullWhenAttribute" />
<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableMemberNotNullWhenAttribute" />

<!--System.Reflection.Metadata-->
<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableMetadataUpdateHandlerAttribute" />

<!--System.Runtime.CompilerServices-->
<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableCreateNewOnMetadataUpdateAttribute" />
<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableIsExternalInit" />
<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableMetadataUpdateOriginalTypeAttribute" />
<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableModuleInitializerAttribute" />
</ItemGroup>
</Project>
12 changes: 11 additions & 1 deletion src/Uno.Extensions.Maui.UI/MauiEmbedding.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Maui.ApplicationModel;
using Uno.Extensions.Hosting;

namespace Uno.Extensions.Maui;
Expand Down Expand Up @@ -91,6 +92,15 @@ public static Microsoft.UI.Xaml.Application UseMauiEmbedding<TApp>(this Microsof

var mauiApp = mauiAppBuilder.Build();
mauiApp.InitializeMauiEmbeddingApp(app);

#if WINDOWS
window.Activated += (s, args) =>
{
WindowStateManager.Default.OnActivated(window, args);
};
#endif


#endif
return app;
}
Expand Down Expand Up @@ -143,7 +153,7 @@ private static void InitializeApplicationMainPage(IApplication iApp)

private static void SetCoreWindow(this IApplication app, Microsoft.Maui.Controls.Window window)
{
if(app.Windows is List<Microsoft.Maui.Controls.Window> windows)
if (app.Windows is List<Microsoft.Maui.Controls.Window> windows)
{
windows.Add(window);
}
Expand Down
5 changes: 0 additions & 5 deletions src/Uno.Extensions.Maui.UI/MauiEmbedding.windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ private static void InitializeMauiEmbeddingApp(this MauiApp mauiApp, Application
throw new MauiEmbeddingException(Properties.Resources.TheApplicationMustInheritFromEmbeddingApplication);
}

//if (_clone is not null)
//{
// app.Resources.Merge(_clone);
//}

embeddingApp.InitializeApplication(mauiApp.Services, iApp);
app.SetApplicationHandler(iApp, rootContext);
InitializeApplicationMainPage(iApp);
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.Extensions.Maui.UI/MauiHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencyObject is not MauiHost mauiHost ||
if(instance is VisualElement visualElement)
{
mauiHost.VisualElement = visualElement;
visualElement.Parent = app;
visualElement.Parent = app.Windows[0];
visualElement.BindingContext = mauiHost.DataContext;
}
else
Expand Down

0 comments on commit 30c52ba

Please sign in to comment.