Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Span cannot be styled for the Dark Mode (it does not support SetAppThemeColor method) #11395

Closed
holecekp opened this issue Jul 10, 2020 · 1 comment

Comments

@holecekp
Copy link

Description

I am converting my project from Xamarin.Forms 4.6 (which used AppThemeColor) to the latest Xamarin.Forms 4.7 (where AppThemeColor has been replaced with AppThemeBinding). The AppThemeBinding is very hard to work with in general. I have found one scenario which I am not able to convert so that it worked in Xamarin.Forms 4.7.

I have created a HyperlinkSpan custom control. However I am not able to set different color for the light mode and for the dark mode. Here is a simplified version of my code:

    public class HyperlinkSpan : Span
    {
        public HyperlinkSpan()
        {
            this.SetAppThemeColor(Span.TextColorProperty, Color.Blue, Color.Aqua);
            // ... setting other things such as underline and a TapGestureRecognizer ...
        }
    }

This code does not compile because Span does not contain definition of SetAppThemeColor. But if a the control would inherit from Label instead of Span, the method could be used (this is however not usable for my case because I need links in a text). After some searching I have found out that SetAppThemeColor is an extension method defined for VisualElement. Label inherits from VisualElement but Span does not.

Expected Behavior

Everything that was possible with AppThemeColor (that was removed from Xamarin.Forms) should be also possible with new AppThemeBinding.

Actual Behavior

Some things that were possible in Xamarin.Forms 4.6 are not possible in 4.7. This can prevent developers from using the current version.

Basic Information

  • Version with issue: Xamarin.Forms 4.7
@holecekp holecekp added s/unverified New report that has yet to be verified t/bug 🐛 labels Jul 10, 2020
@PureWeen
Copy link
Contributor

@StephaneDelcroix

@jsuarezruiz jsuarezruiz removed the s/unverified New report that has yet to be verified label Jul 13, 2020
StephaneDelcroix added a commit that referenced this issue Jul 15, 2020
what's possible in xaml should be possible in code

- fixes #11395
StephaneDelcroix added a commit that referenced this issue Jul 15, 2020
what's possible in xaml should be possible in code

- fixes #11395
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants