Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label FormattedString not reacting to AppThemeBinding change at runtime #17938

Closed
davidortinau opened this issue Oct 10, 2023 · 3 comments
Closed
Assignees
Labels
area-controls-label Label, Span fixed-in-8.0.0-rc.2.9511 Look for this fix in 8.0.0-rc.2.9511 migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@davidortinau
Copy link
Contributor

davidortinau commented Oct 10, 2023

Description

When changing the theme at runtime on Android or iOS, the implicit TextColor on a Label style is not being respected. Restarting the app is accurate. I tried .NET 8 RC2 and .NET 7 - 7.0.96.

<Label 
    SemanticProperties.HeadingLevel="Level2">
    <Label.FormattedText>
        <FormattedString>
            <Span Text=".NET MAUI uses the latest technologies for building native apps on Windows, macOS, iOS, and Android, abstracting them into one common framework built on .NET." />
            <Span Text="&#10;&#10;"/>
            <Span Text="Use a single C# codebase and project system for all device targets to build apps that look and feel like the native platforms." />
            <Span Text="&#10;&#10;"/>
            <Span Text="Build beautiful apps faster and easier by integrating the power of Visual Studio with .NET MAUI." />
        </FormattedString>
    </Label.FormattedText>
</Label>   
<Style TargetType="Label">
    <Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource White}}"/>
</Style>
bad.mp4

Setting the same on a Span type style does work.

<Style TargetType="Span">
    <Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource White}}"/>
</Style>
good.mp4

Project:

templatetweak.zip

Steps to Reproduce

Go into the styles.xaml file of the attached file and comment out this line

   <Style TargetType="Span">
       <Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource White}}"/>
   </Style>
  • run the app
  • change the theme of the device from light to dark (or visa versa) and notice that the text inside the span doesn't update.

Link to public reproduction project repository

No response

Version with bug

8.0.0-rc.2

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms (confirmed in attached)

XamarinLabelRepro.zip

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

No response

Did you find any workaround?

Styling the Span instead of just the Label.

Relevant log output

No response

@davidortinau davidortinau added t/bug Something isn't working potential-regression This issue described a possible regression on a currently supported version., verification pending labels Oct 10, 2023
@PureWeen PureWeen added this to the .NET 8 GA milestone Oct 10, 2023
@jsuarezruiz jsuarezruiz added the area-controls-label Label, Span label Oct 11, 2023
@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Oct 11, 2023
@PureWeen PureWeen added the migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert label Oct 11, 2023
@samhouts samhouts removed the potential-regression This issue described a possible regression on a currently supported version., verification pending label Oct 14, 2023
@XamlTest XamlTest added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Oct 16, 2023
@XamlTest
Copy link
Collaborator

Verified this on Visual Studio Enterprise 17.8.0 Preview 3.0(8.0.0-rc.2.9373). Repro on Android 13.0-API33 and iOS 16.4, not repro on Windows 11 with below Project:
templatetweak (2).zip

@mattleibow mattleibow self-assigned this Oct 17, 2023
@mattleibow
Copy link
Member

Looking at the code, this code specifically does this:

image

Need to test on other platforms to see how they handle this.

@mattleibow

This comment was marked as outdated.

@ghost ghost locked as resolved and limited conversation to collaborators Nov 22, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-label Label, Span fixed-in-8.0.0-rc.2.9511 Look for this fix in 8.0.0-rc.2.9511 migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 platform/iOS 🍎 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

7 participants