xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.87k forks source link

[Bug] UWP NavigationPage.TitleView does not fill Header #8602

Open YZahringer opened 4 years ago

YZahringer commented 4 years ago

Description

On UWP the TitleView does not take up all the available space. There is a margin at the bottom and left.

Steps to Reproduce

<ContentPage>
    <NavigationPage.TitleView>
        <Grid
            BackgroundColor="Red"
            HorizontalOptions="FillAndExpand"
            VerticalOptions="FillAndExpand" />
    </NavigationPage.TitleView>

    <Grid BackgroundColor="Yellow">

    </Grid>
</ContentPage> 

Expected Behavior

Grid with BackgroundColor="Red" Fill Header without margins: image

Actual Behavior

Grid has Left 10px and Bottom 8px Margin: image Live Visual Tree of Header: image It is the Border in TitleViewPresenter that takes width=10px and height=48px. This one should have Visibility=Collapsed.

Basic Information

jfversluis commented 4 years ago

Hm I wonder if this has some connection to what is going on in #5661

YZahringer commented 4 years ago

@jfversluis Thanks! This also fixes the left "Padding" on TitleView?

jfversluis commented 4 years ago

Hm that I don't think so, this focusses mostly on the bottom thing. But it should be in the same area

jfversluis commented 4 years ago

Confirmed this happening in the attached repro project.

Repro8602.zip

WayaFlyfeather commented 4 years ago

I've tried to look into this. It appears the implementation of the TitleView in UWP is such, that it co-exists with the TitleIcon and Title properties, and this is causing the problems.

This becomes more obvious if a Title is added to the repro @jfversluis provided: 2019-12-26

Note how the "Title" intrudes on the TitleView.

The left padding is caused by these lines in the default PageControlStyle - where a grid with 3 columns are used: one for any icon, one for the title, and one for the TitleView. As the TextBlock for the Title includes a left padding of 10, this is always there.

I can fix this, but I need to be sure my understanding is correct: that if a TitleView is specified, this should take precedence, and neither the Icon ot the Title property should be shown; but if no TitleView is specified, the Icon and Title should be shown.

?

YZahringer commented 4 years ago

My temp workaround (hide TextBlock of Title in entire app):

<Application.Resources>
    <Style x:Key="TitleTextBlockStyle" TargetType="TextBlock">
        <Setter Property="Visibility" Value="Collapsed" />
    </Style>

    <x:Double x:Key="AppBarThemeCompactHeight">48</x:Double>
    <x:Double x:Key="AppBarExpandButtonThemeWidth">0</x:Double>
</Application.Resources>

In my opinion, the Title TextBlock should be collapsed when no Title provided.

YZahringer commented 3 years ago

Issue persists on XF 5.0.0.1829-pre6

Repro project: bug-uwp-titleview