Skip to content

[Windows] Fix titlebar not persisting when page is swapped#27192

Merged
PureWeen merged 3 commits intomainfrom
foda/TBPageSwitch
Jan 28, 2025
Merged

[Windows] Fix titlebar not persisting when page is swapped#27192
PureWeen merged 3 commits intomainfrom
foda/TBPageSwitch

Conversation

@Foda
Copy link
Copy Markdown
Contributor

@Foda Foda commented Jan 16, 2025

Description of Change

  • Fix titlebar not being transferred when page is swapped
  • Fix titlebar leaking when replaced

Issues Fixed

Fixes #27170

Fix titlebar leaking events when replaced
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • src/Core/src/Platform/Windows/NavigationRootManager.cs: Evaluated as low risk
  • src/Core/src/Platform/Windows/WindowRootView.cs: Evaluated as low risk
Comments suppressed due to low confidence (1)

src/Controls/src/Core/Window/Window.cs:395

  • Ensure that there are test cases covering the cleanup and reattachment of the title bar when the page is swapped.
prevTitleBar.Cleanup();

@PureWeen PureWeen added this to the .NET 9 SR3.1 milestone Jan 17, 2025
Comment thread src/Controls/src/Core/TitleBar/TitleBar.cs
Copy link
Copy Markdown
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Playing with this it seems like the TitleBar still disappears?

tested in the sandbox

return new Window(new NavigationPage(new MainPage()))
{
	TitleBar = new TitleBar
	{
		BackgroundColor = Colors.Red,
		ForegroundColor = Colors.White,
		Subtitle = "Subtitle",
	}
};

Then in MainPage I swapped out the Page on Window

  <VerticalStackLayout>
    <Button Text="me" Clicked="Button_Clicked"></Button>
  </VerticalStackLayout>
	private void Button_Clicked(object sender, EventArgs e)
	{

		this.Window.Page = new MainPage();

    }

The TitleBar seems to reset when the page is swapped

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Jan 23, 2025

Playing with this it seems like the TitleBar still disappears?

tested in the sandbox

Nevermind.....
I messed up the branch I was testing on and it didn't have your changes

Remove unneeded TB removal
Add leak test
}

SetToolbar(null);
SetTitleBar(null, null);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add this call up into the WindowHandler.Disconnect code?

I think it's still useful to set the TitleBar to null if the handler itself is being disconnected

so we can add it here
image

after the disconnect call

@PureWeen PureWeen modified the milestones: .NET 9 SR3.1, .NET 9 SR4 Jan 28, 2025
@PureWeen PureWeen merged commit 3268462 into main Jan 28, 2025
@PureWeen PureWeen deleted the foda/TBPageSwitch branch January 28, 2025 15:16
@github-actions github-actions bot locked and limited conversation to collaborators Feb 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Version 9.0.30] Window.TitleBar is set to null after changing Window.Page at runtime

3 participants