[Mac] TitleBar not always initally set #27487
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
When the TitleBar on MacCatalyst is set, on the initial page, it would not always display properly. The size and color would show up, but the page would not shift its content below the TitleBar and no elements would show inside the TitleBar. In a simple shell page, this behavior was not observed. However, it was observed inside a NavigationPage. In the NavigationPage example, if I pushed another ContentPage with the TitleBar set there, the titleBar would then display correctly.
The issue lied in the
SetUpTitleBar
method in theWindowViewController.cs
file when comparingif (newTitleBar != iTitleBar)
. In the NavigationPage scenario, the initialwindow.TitleBar?.ToPlatform(mauiContext);
was not null. Then when the MapTitleBar called SetUpTitleBar again, there would be a second comparison of two different types which would then null out our original TitleBar and remove the handler. When the handler was removed, everything would be reset leading to our elements in the titlebar not being displayed and the window content not shifting.Issues Fixed
Fixes #27413