Skip to content

Fixed NavigationPage TitleBar visibility issue when set to the parent page #25000

Closed
Vignesh-SF3580 wants to merge 6 commits intodotnet:mainfrom
Vignesh-SF3580:fix-13807
Closed

Fixed NavigationPage TitleBar visibility issue when set to the parent page #25000
Vignesh-SF3580 wants to merge 6 commits intodotnet:mainfrom
Vignesh-SF3580:fix-13807

Conversation

@Vignesh-SF3580
Copy link
Copy Markdown
Contributor

@Vignesh-SF3580 Vignesh-SF3580 commented Sep 30, 2024

Root Cause

The NavigationBar stayed visible because only the current page's HasNavigationBar property was checked, ignoring the parent
NavigationPage's setting when it was false.

Description of Change

The fix now checks both the parent NavigationPage and current page’s HasNavigationBar property. This ensures the NavigationBar is hidden when either the parent or current page has HasNavigationBar set to false.

Issues Fixed

Fixes #13807
Fixes #16816

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Screenshots

Before
image

After
image

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Sep 30, 2024
@Vignesh-SF3580 Vignesh-SF3580 marked this pull request as ready for review October 3, 2024 10:46
@Vignesh-SF3580 Vignesh-SF3580 requested a review from a team as a code owner October 3, 2024 10:46
@jfversluis
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Oct 3, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

public void NavigationBarVisibility()
{
App.WaitForElement("label");
VerifyScreenshot();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Triggered the build, it should generate the reference snapshot for this test.

@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Copy Markdown
Contributor

/rebase

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Oct 9, 2024

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Copy Markdown
Member

PureWeen commented Oct 9, 2024

I think this one is going to require some additional design decisions. For example, if you nest the contentpage inside another layer

<TabbedPage
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="Maui.Controls.Sample.MainPage"
    xmlns:local="clr-namespace:Maui.Controls.Sample"
    NavigationPage.HasNavigationBar="False"
    >

    <TabbedPage>
        <ContentPage Title="Title 1"></ContentPage>
    </TabbedPage>
    <TabbedPage>
        <ContentPage Title="Title 2"></ContentPage>
    </TabbedPage>
</TabbedPage>

This fix doesn't really work.

Generally, with any extension properties it has to be applied to the ContentPage being displayed. If we want this to work hierarchically then we'd need to apply this logic to all of the attached properties for consistency

image

Plus we'd want to apply this logic to TabbedPage extension properties as well.

One way users can get around this is by setting a resource on the TabbedPage that will set this on all ContentPages

 <TabbedPage.Resources>
        <Style TargetType="ContentPage">
            <Setter Property="NavigationPage.HasNavigationBar" Value="False" />
        </Style>
    </TabbedPage.Resources>

I'm going to close this one for now. We can look at making all of these attached properties inheritable at a later point in time

@PureWeen PureWeen closed this Oct 9, 2024
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 9, 2024
@sheiksyedm sheiksyedm added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-titlebar area-navigation NavigationPage community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] NavigationPage.HasNavigationBar="False" doesn't work with TabbedPage NavigationPage TitleBar Persists if child pages have a title

5 participants