Skip to content
10 changes: 6 additions & 4 deletions src/Controls/src/Core/TabbedPage/TabbedPage.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ private protected override void OnHandlerChangedCore()

partial void OnHandlerChangingPartial(HandlerChangingEventArgs args)
{
if (args?.OldHandler?.PlatformView is FrameworkElement fe)
OnHandlerDisconnected(fe);
OnHandlerDisconnected((ElementHandler?)(args?.OldHandler));
}

void OnHandlerConnected()
Expand Down Expand Up @@ -116,7 +115,7 @@ void SetupNavigationLocals()
}
}

void OnHandlerDisconnected(FrameworkElement? platformView)
void OnHandlerDisconnected(ElementHandler? elementHandler)
{
if (!_connectedToHandler)
return;
Expand All @@ -128,13 +127,16 @@ void OnHandlerDisconnected(FrameworkElement? platformView)
_navigationView.SizeChanged -= OnNavigationViewSizeChanged;
}

if (platformView is WFrame wFrame)
if (elementHandler?.PlatformView is WFrame wFrame)
wFrame.Navigated -= OnNavigated;

Appearing -= OnTabbedPageAppearing;
Disappearing -= OnTabbedPageDisappearing;
if (_navigationView != null)
{
_navigationView.SelectedItem = null;
_navigationView.SelectionChanged -= OnSelectedMenuItemChanged;
}

OnTabbedPageDisappearing(this, EventArgs.Empty);

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue26096.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
namespace Maui.Controls.Sample.Issues
{

[Issue(IssueTracker.Github, 26069, "The TabbedPage selection indicator is not updated properly when reloading the TabbedPage with a new instance",
PlatformAffected.UWP)]
public class Issue26069 : TestContentPage
{
protected override void Init()
{
Button tabbedPageButton = new Button();
tabbedPageButton.AutomationId = "OpenTabbedPage";
tabbedPageButton.HorizontalOptions = LayoutOptions.Center;
tabbedPageButton.VerticalOptions = LayoutOptions.Center;
tabbedPageButton.Text = "Open Tabbed Page";
tabbedPageButton.Clicked += TabbedPageButton_Clicked;

VerticalStackLayout layout = new VerticalStackLayout();
layout.VerticalOptions = LayoutOptions.Center;
layout.Children.Add(tabbedPageButton);
Content = layout;
}

private async void TabbedPageButton_Clicked(object sender, EventArgs e)
{
await Navigation.PushModalAsync(new NavigationPage(new Issue26069TabbedPage()));
}
}

public class Issue26069TabbedPage : TabbedPage
{
public Issue26069TabbedPage()
{
ContentPage page1 = new ContentPage();
page1.Title = "Page 1";

ContentPage page2 = new ContentPage();
page2.Title = "Page 2";

ContentPage page3 = new ContentPage();
page3.Title = "Page 3";

this.Children.Add(page1);
this.Children.Add(page2);
this.Children.Add(page3);
ToolbarItems.Add(new ToolbarItem("Back", null, async () =>
{
await Navigation.PopModalAsync(true);
}));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue26096 : _IssuesUITest
{

public Issue26096(TestDevice device) : base(device)
{
}

public override string Issue => "The TabbedPage selection indicator is not updated properly when reloading the TabbedPage with a new instance";

[Test]
[Category(UITestCategories.TabbedPage)]
public void UpdatedSelectionIndicatorProperly()
{
App.WaitForElement("OpenTabbedPage");
App.Tap("OpenTabbedPage");
#if __ANDROID__
App.Tap("PAGE 3");
#elif __IOS__ || WINDOWS || MACCATALYST
App.Tap("Page 3");
#endif
App.Tap("Back");
App.WaitForElement("OpenTabbedPage");
App.Tap("OpenTabbedPage");
VerifyScreenshot();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading