Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Set Parent to be Window (backport #1816) #1828

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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