Skip to content

Commit

Permalink
RootPanel is no longer needed (#7172)
Browse files Browse the repository at this point in the history
  • Loading branch information
hartez committed May 13, 2022
1 parent 8383b6f commit 25b4b6f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 79 deletions.
29 changes: 1 addition & 28 deletions src/Core/src/Handlers/Window/WindowHandler.Windows.cs
@@ -1,38 +1,16 @@
using System;
using Microsoft.UI.Xaml.Controls;
using WThickness = Microsoft.UI.Xaml.Thickness;

namespace Microsoft.Maui.Handlers
{
public partial class WindowHandler : ElementHandler<IWindow, UI.Xaml.Window>
{
RootPanel? _rootPanel = null;

protected override void ConnectHandler(UI.Xaml.Window platformView)
{
base.ConnectHandler(platformView);

if (_rootPanel == null)
{
// TODO WINUI should this be some other known constant or via some mechanism? Or done differently?
MauiWinUIApplication.Current.Resources.TryGetValue("MauiRootContainerStyle", out object? style);

_rootPanel = new RootPanel
{
Style = style as UI.Xaml.Style
};
}

platformView.Content = _rootPanel;
}

protected override void DisconnectHandler(UI.Xaml.Window platformView)
{
MauiContext
?.GetNavigationRootManager()
?.Disconnect();

_rootPanel?.Children?.Clear();
platformView.Content = null;

base.DisconnectHandler(platformView);
Expand All @@ -47,13 +25,8 @@ public static void MapContent(IWindowHandler handler, IWindow window)
var windowManager = handler.MauiContext.GetNavigationRootManager();
windowManager.Disconnect();
windowManager.Connect(handler.VirtualView.Content.ToPlatform(handler.MauiContext));
var rootPanel = handler.PlatformView.Content as Panel;

if (rootPanel == null)
return;

rootPanel.Children.Clear();
rootPanel.Children.Add(windowManager.RootView);
handler.PlatformView.Content = windowManager.RootView;

if (window.VisualDiagnosticsOverlay != null)
window.VisualDiagnosticsOverlay.Initialize();
Expand Down
49 changes: 0 additions & 49 deletions src/Core/src/Platform/Windows/RootPanel.cs

This file was deleted.

2 changes: 0 additions & 2 deletions src/Core/src/Platform/Windows/Styles/Resources.xaml
Expand Up @@ -15,8 +15,6 @@

<windows:ColorConverter x:Key="ColorConverter" />

<Style x:Key="MauiRootContainerStyle" TargetType="Panel" />

<Style x:Key="MauiFlyoutPresenterStyle" TargetType="FlyoutPresenter">
<Setter Property="MaxHeight" Value="250"/>
<Setter Property="MaxWidth" Value="300"/>
Expand Down

0 comments on commit 25b4b6f

Please sign in to comment.