From d9829de0c81f01f9675fcbd38af3ec837f28d5af Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Mon, 14 Oct 2024 13:34:45 +0200 Subject: [PATCH] fix: Adjust NativeFramePresenter to work with new TemplatedParent implementation --- .../Controls/NavigationBar/NativeFramePresenter.Android.cs | 7 ++++--- .../Controls/NavigationBar/NativeFramePresenter.iOS.cs | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Uno.Toolkit.UI/Controls/NavigationBar/NativeFramePresenter.Android.cs b/src/Uno.Toolkit.UI/Controls/NavigationBar/NativeFramePresenter.Android.cs index 20d5a793e..2ac1e10e3 100644 --- a/src/Uno.Toolkit.UI/Controls/NavigationBar/NativeFramePresenter.Android.cs +++ b/src/Uno.Toolkit.UI/Controls/NavigationBar/NativeFramePresenter.Android.cs @@ -45,12 +45,13 @@ public partial class NativeFramePresenter : Grid // Inheriting from Grid is a ha public NativeFramePresenter() { _pageStack = this; + + this.Loaded += OnLoaded; } - protected override void OnTemplatedParentChanged(DependencyPropertyChangedEventArgs e) + private void OnLoaded(object sender, RoutedEventArgs e) { - base.OnTemplatedParentChanged(e); - Initialize(TemplatedParent as Frame); + Initialize(this.FindFirstParent()); } private void Initialize(Frame? frame) diff --git a/src/Uno.Toolkit.UI/Controls/NavigationBar/NativeFramePresenter.iOS.cs b/src/Uno.Toolkit.UI/Controls/NavigationBar/NativeFramePresenter.iOS.cs index 4bac0d3ae..6f022121d 100644 --- a/src/Uno.Toolkit.UI/Controls/NavigationBar/NativeFramePresenter.iOS.cs +++ b/src/Uno.Toolkit.UI/Controls/NavigationBar/NativeFramePresenter.iOS.cs @@ -107,12 +107,12 @@ public NativeFramePresenter() SizeChanged += NativeFramePresenter_SizeChanged; // Hide the NavigationBar by default. Only show if navigating to a Page that contains a NavigationBar. NavigationController.NavigationBarHidden = true; + this.Loaded += OnLoaded; } - protected override void OnTemplatedParentChanged(DependencyPropertyChangedEventArgs e) + private void OnLoaded(object sender, RoutedEventArgs e) { - base.OnTemplatedParentChanged(e); - InitializeController(TemplatedParent as Frame); + InitializeController(this.FindFirstParent()); } ///