maui icon indicating copy to clipboard operation
maui copied to clipboard

[WinUI3] TitleView content does not expand across the entire width

Open Agredo opened this issue 3 years ago • 10 comments

I am trying to port an app from XF with UWP to MAUI with WinUI3.

The Shell.TabView does not work correctly in MAUI. The content is not expanding horizontally. I can manually make the buttons wider but then its not more adaptive to the windows size. image

Here is the copy and pasted Xamarin Forms code for the used NavigationPage.TitleView (The old project did not use Shell) `
<Shell.TitleView>

    <Grid ColumnDefinitions="Auto, *, *, *, *" HorizontalOptions="FillAndExpand">

        <Image Grid.Column="0" Source="butenunbinnen_logo.png" HorizontalOptions="Start" HeightRequest="40" VerticalOptions="Start" Margin="24,0,12,0"/>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <Button Grid.Column="1" Text="&#xE094;" Background="#29455A" TextColor="White" Command="{Binding SearchLabelCommand}" FontSize="Small">
            <Button.FontFamily>
                <OnPlatform x:TypeArguments="x:String">
                    <On Platform="UWP" Value="Segoe MDL2 Assets"/>
                    <On Platform="iOS,Android" Value="SegoeMDL2"/>
                </OnPlatform>
            </Button.FontFamily>
        </Button>

        <Button Grid.Column="2" Text="&#xE115;" TextColor="White" CornerRadius="5" Background="#29455A"  Command="{Binding SettingButtonCommand}">
            <Button.FontFamily>
                <OnPlatform x:TypeArguments="x:String">
                    <On Platform="UWP" Value="Segoe MDL2 Assets"/>
                    <On Platform="Android, iOS" Value="SegoeMDL2"/>
                </OnPlatform>
            </Button.FontFamily>
        </Button>

        <Label Grid.Column="3" HorizontalOptions="FillAndExpand" HorizontalTextAlignment="Center" Background="#29455A" TextColor="White" VerticalTextAlignment="Center" Margin="0,0,0,0">
            <Label.GestureRecognizers>
                <TapGestureRecognizer Command="{Binding TrafficButtonCommand}"/>
            </Label.GestureRecognizers>

            <Label.FormattedText>
                <FormattedString>
                    <Span FontSize="Small" FontAttributes="Bold" Text="&#xE7EC;">
                        <Span.FontFamily>
                            <OnPlatform x:TypeArguments="x:String">
                                <On Platform="UWP" Value="Segoe MDL2 Assets"/>
                                <On Platform="iOS,Android" Value="SegoeMDL2"/>
                            </OnPlatform>
                        </Span.FontFamily>
                    </Span>
                    <Span FontSize="Small" FontAttributes="Bold" Text="{Binding TrafficButtonText}"/>
                </FormattedString>
            </Label.FormattedText>
        </Label>

        <Button Grid.Column="4" TextColor="White" FontSize="Small" FontAttributes="Bold" Text="&#xE1CF;" CornerRadius="5" Background="#29455A" Command="{Binding FavoriteButtonCommand}">
            <Button.FontFamily>
                <OnPlatform x:TypeArguments="x:String">
                    <On Platform="UWP" Value="Segoe MDL2 Assets"/>
                    <On Platform="Android, iOS" Value="SegoeMDL2"/>
                </OnPlatform>
            </Button.FontFamily>
        </Button>
    </Grid>
</Shell.TitleView>

`

Agredo avatar Oct 15 '22 17:10 Agredo

Potentially fixed by https://github.com/dotnet/maui/pull/10768

rachelkang avatar Oct 21 '22 14:10 rachelkang

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Oct 21 '22 14:10 ghost

Hello, i have the same problem. It seems that the TitleView always has the width of its content, so its not possible to center an image/logo in the TitleView, or do that what @Agredo wanted to do.

Dry-Tech avatar Apr 12 '23 11:04 Dry-Tech

This is not fixed still.

daltzctr avatar May 22 '23 17:05 daltzctr

Verified this issue with Visual Studio Enterprise 17.8.0 Preview 1.0. Can repro this issue with sample code.

homeyf avatar Sep 12 '23 09:09 homeyf

Still an issue with VS 17.8.3

devdeer-alex avatar Dec 30 '23 21:12 devdeer-alex

Only (very dirty!!!) workaround I found so far:

<NavigationPage.TitleView>
    <Grid WidthRequest="{Binding Source={RelativeSource Self}, Path=Window.Width}">

    </Grid>
</NavigationPage.TitleView>

devdeer-alex avatar Dec 30 '23 22:12 devdeer-alex

Are there any updates on this? Seems the issue still persists in .NET8

schinkenwuerfel avatar Mar 14 '24 10:03 schinkenwuerfel

Any updates on this?

pme442 avatar Apr 17 '24 11:04 pme442

Is this being worked on?

rezamohamed avatar May 23 '24 14:05 rezamohamed