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.21k stars 1.75k forks source link

AppThemeBinding BarBackground with Brush in NavigationPage and TabbedPage not working #24356

Open AlleSchonWeg opened 2 months ago

AlleSchonWeg commented 2 months ago

Description

Hi, if you set a brush as BarBackground in a TabbedPage or in a NavigationPage Style with AppThemeBinding the colors are not changed if the user change the theme. Sample:

  <TabbedPage.BarBackground>
    <LinearGradientBrush StartPoint="0,0"
                         EndPoint="0,1">
      <GradientStop Color="{AppThemeBinding Light=Red, Dark=Brown}"
                    Offset="0.0" />
      <GradientStop Color="{AppThemeBinding Light=Green, Dark=Yellow}"
                    Offset="0.5" />
      <GradientStop Color="{AppThemeBinding Light=Green, Dark=Yellow}"
                    Offset="0.5" />
      <GradientStop Color="{AppThemeBinding Light=Red, Dark=Brown}"
                    Offset="1.0" />
    </LinearGradientBrush>
  </TabbedPage.BarBackground>
  <Style TargetType="NavigationPage">
    <Setter Property="BarBackground">
      <OnPlatform x:TypeArguments="Brush">
        <On Platform="Android">
          <LinearGradientBrush StartPoint="0,0"
                               EndPoint="0,1">
            <GradientStop Color="{AppThemeBinding Light=Red, Dark=Brown}"
                          Offset="0.0" />
            <GradientStop Color="{AppThemeBinding Light=Green, Dark=Yellow}"
                          Offset="0.5" />
            <GradientStop Color="{AppThemeBinding Light=Green, Dark=Yellow}"
                          Offset="0.5" />
            <GradientStop Color="{AppThemeBinding Light=Red, Dark=Brown}"
                          Offset="1.0" />
          </LinearGradientBrush>
        </On>
        <On Platform="iOS">
          <SolidColorBrush Color="{AppThemeBinding Light=Red, Dark=Green}" />
        </On>
      </OnPlatform>
    </Setter>
    <Setter Property="BarTextColor"
            Value="{AppThemeBinding Light=Blue, Dark=Yellow}" />
  </Style>

Setting BarBackground={AppThemeBinding Light=Red, Dark=Brown} works.

Steps to Reproduce

NavigationPage and TabbedPage background should change the colors.

I tested only Android. Please check also iOS if it works as expected. Version: 8.0.90-ci.net8.24420.2 MauiApp6.zip

Link to public reproduction project repository

No response

Version with bug

Nightly / CI build (Please specify exact version)

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

github-actions[bot] commented 2 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

kevinxufei commented 2 months ago

I can repro this issue at Android/iOS platforms on the latest 17.12.0 Preview 1.0(8.0.90-ci.net8.24420.2 & 8.0.80). The dark/light system theme changes, but the background color does no change.