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.04k stars 1.73k forks source link

[regression/7.0.0] Back button image color can't be changed #17228

Open JRosanowski opened 1 year ago

JRosanowski commented 1 year ago

Description

It looks like this was fixed for .NET Maui 6 but is broken in .NET Maui 7. I haven't tried .NET Maui 8. It's mainly a problem if you want to use a white title bar. The back button image can't be seen. https://github.com/dotnet/maui/issues/11127

image

Steps to Reproduce

No response

Link to public reproduction project repository

https://github.com/Sebosek/MAUI.IconColorBug

Version with bug

7.0.92

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

6.0

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

Android 13

Did you find any workaround?

No workaround

Relevant log output

No response

XamlTest commented 1 year ago

Verified this on Visual Studio Enterprise 17.8.0 Preview 1.0. Repro on Android 13.0-API33 and iOS 16.4 (8.0.0-preview.7.8842) with below Project: BackIconColor.zip

jsuarezruiz commented 11 months ago

Are you using the Shell.ForegroundColor property?. It works using .NET 8, need to do more tests using .NET 6 and 7.

TrueMoniker commented 9 months ago

To add more context to @jsuarezruiz answer:

The toolbar item color is decided by the Shell.Foreground color. You can set it on the ContentPage

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MyPage"
             Shell.ForegroundColor="Red">

If you want to set the color for each content page, set it in the Resources/styles.xml

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
    <Style TargetType="ContentPage"
           ApplyToDerivedTypes="True">
        <!--Change the toolbar button colors-->
        <Setter Property="Shell.ForegroundColor" Value="Black" />
    </Style>
</ResourceDictionary>
acaliaro commented 8 months ago

Are you using the Shell.ForegroundColor property?. It works using .NET 8, need to do more tests using .NET 6 and 7.

@jsuarezruiz , Shell.ForegroundColor works for default back button.

    <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiApp7.NewPage1"
             Shell.ForegroundColor="Red"
             Shell.BackgroundColor="HotPink"
             Title="NewPage1">

    <Shell.BackButtonBehavior>
        <BackButtonBehavior IsVisible="True" IconOverride="dotnet_bot"/>
    </Shell.BackButtonBehavior>
    <VerticalStackLayout>
        <Label 
            Text="Welcome to .NET MAUI!"
            VerticalOptions="Center" 
            HorizontalOptions="Center" />
    </VerticalStackLayout>
</ContentPage>

If you override the default back button, Shell.ForegroundColor does not work and the icon color is always white

image

HuaFangYun commented 6 months ago

Maui8.0.7 Maui8.0.14 Having the same issue here. Custom back button is always white, any fix on the horizon?

acaliaro commented 3 months ago

@samhouts any news about this?

nshtinkov commented 1 month ago

Same problem here, VS 17.11.1, MAUI 8.0.80.

rezamohamed commented 1 week ago

Same problem with .NET 8.0.90 (a year after it was first reported) https://github.com/dotnet/maui/issues/24857

kubaflo commented 2 days ago

Hi, @acaliaro @nshtinkov @rezamohamed fixed here :) https://github.com/dotnet/maui/pull/24993