dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.16k stars 1.74k forks source link

NavigationPage.TitleView displays incorrectly on Windows #16149

Open RWSchwabXXX opened 1 year ago

RWSchwabXXX commented 1 year ago

Description

When using a custom NavigationPage.TitleView compiled for Windows it displays incorrectly. partial screenshots of identical code run on Windows and Andriod are below. The windows version pushes everything to the start of the Title view and only extends the width of the encompasing grid to the largest child - rather than the width of the window. Setting HorizontalOptions on the grid (or any of the children) to fill do not change affect the display.

Windows image

Android image

The ImageButton also displays differently, but that is of minor importance.

Steps to Reproduce

Set the NavigationPage.TitleView in XAML for a ContentPage.

  <NavigationPage.TitleView>
    <Grid  >
      <Label Text="Home Page" HorizontalOptions="StartAndExpand" VerticalOptions="Center" TextColor="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource White}}" FontSize="Large"   />
      <Button Text="test" HorizontalOptions="Center" ImageSource="plus32.png" TextColor="White" />
      <ImageButton Command="{x:Binding TakePicture}" Source="camera_plus_32.png" HorizontalOptions="End" HeightRequest="32"/>
    </Grid>
  </NavigationPage.TitleView>

The content page is used to instantiate the main NavigationPage:

  public App(IServiceProvider services) {
    InitializeComponent();
    MainPage = new NavigationPage(services.GetService<Pages.PhotosHomePage>());
  }

Link to public reproduction project repository

https://github.com/RWSchwabXXX/TitleviewProblemRepro

Version with bug

8.0.0-preview.6.8686

Last version that worked well

unknown

Affected platforms

Windows

Affected platform versions

windows10.0.19041.0

Did you find any workaround?

Setting the WidthRequest of the grid within the TitleView helps, but it would need to be bound to the window width.

Relevant log output

No response

ghost commented 1 year ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

XamlTest commented 1 year ago

Verified this on Visual Studio Enterprise 17.7.0 Preview 6.0. Repro on Windows 11(8.0.100-preview.6.23330.14), not repro on Android 13.0-API33 and iOS 16.4 with below Project: TitleviewProblemRepro.zip

egvijayanand commented 9 months ago

Yes, the NavigationBar TitleView does not expand to occupy the entire title bar even if the HorizontalOptions of the container control is set to Fill. Issue in the Windows platform.

<NavigationPage.TitleView>
  <Grid BackgroundColor="Yellow"><Label Text="Home" /></Grid>
</NavigationPage.TitleView>
pme442 commented 1 month ago

Any updates on fixing this, or workarounds??