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

Span doesn't have a StyleClass property #16432

Open JohnHDev opened 1 year ago

JohnHDev commented 1 year ago

Description

As per title, it means we cannot specify different theme colours for different spans within a label from a style.

Steps to Reproduce

Can't reproduce something that doesn't exist. ;)

Link to public reproduction project repository

nope

Version with bug

7.0.49

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows, macOS, Other (Tizen, Linux, etc. not supported by Microsoft directly)

Affected platform versions

all

Did you find any workaround?

Trying to remove the need for separate colours in spans, but the business won't really accept that. Separate issue was raised as even when we did use a single colour defined on the style of the label itself, it doesn't respond to theme changes.

Relevant log output

No response

ghost commented 1 year ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

eth-ellis commented 3 months ago

This would be very useful!

Seems to be because Style/StyleClass come from Element -> NavigableElement, whereas Span derives from Element -> GestureElement and implements it's own version of Style but not StyleClass.

NavigableElement

Span

eth-ellis commented 3 months ago

It would also be great if Span supported Triggers i.e. DataTrigger.

Anyone know why Span does not derive from VisualElement?

kiddailey commented 3 months ago

Adding my vote as well -- this was asked for in Xamarin many years ago as well and was never added :( At the very least, it would be nice if Spans inherited the class from the parent Label so we could target them appropriately. Edit: Additionally, there appears to be no way to assign multiple classes to a Span due to this.