maui icon indicating copy to clipboard operation
maui copied to clipboard

Implicit styling on .NET 8 is being ignored on the page level

Open BFuchshofer opened this issue 7 months ago • 4 comments

Description

The implicit styling set on the page level does not utilize implicit styling on the application level.

Example: There is a styling with TargetType="Label" on the application level that sets the TextColor to Red and the background color to Yellow. There is a Label on the MainPage with no inline styling set. However, on the page level, there exists a styling with TargetType="Label" and a Setter for the TextColor set to Green.

The expected behavior is that the Label has a Green TextColor and a Yellow BackgroundColor. The behavior on .NET 7 and .NET 8 is different. It works on .NET 7 but not on .NET 8. On .NET 8, all stylings from the application level are being ignored.

.Net 7 Screenshot_20240111_110339

.Net 8 Screenshot_20240111_110331

Steps to Reproduce

No response

Link to public reproduction project repository

https://github.com/BFuchshofer/StyleTest

Version with bug

8.0.5

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI, Yes, this used to work in Xamarin.Forms

Last version that worked well

7.0.101

Affected platforms

iOS, Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

BFuchshofer avatar Jan 11 '24 10:01 BFuchshofer

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.

ghost avatar Jan 11 '24 19:01 ghost

It looks like Styles set over VisualStateGroups on Applicationlevel still work on Page Level when used in an implicit Style (no x:Key set, just TargetType).

BFuchshofer avatar Jan 12 '24 12:01 BFuchshofer

It looks like Styles set over VisualStateGroups on Applicationlevel still work on Page Level when used in an implicit Style (no x:Key set, just TargetType).

I've been looking for a work around for nearly all of my global styles breaking when I moved to .net 8.0 and I used your work around to fix my issue so thank you. It appears that when you specify a visual state setter globally and then specify some property at the page level for any control, it overrides the global style unless its inside of the normal state.

Alex-J-Lopez avatar Jan 26 '24 15:01 Alex-J-Lopez

I really wonder why there are no other developers experiencing this issue. I couldn't find any other evidence that this problem exists for other people. So, I wonder what I am doing wrong.

BFuchshofer avatar Jan 27 '24 12:01 BFuchshofer

I've been looking around and I also can't seem to find any other instance of this happening. I've converted all of my styles to set properties inside of the normal visual state which seems to fix the issue for me. So long as I overwrite the styles in the normal visual state in the content page, it still accepts the global style.

Alex-J-Lopez avatar Jan 29 '24 22:01 Alex-J-Lopez

Verified this on Visual Studio Enterprise 17.10.0 Preview 1(8.0.6). Repro on Windows 11, Android 14.0-API34, iOS 17.2 and MacCatalyst with below Project: StyleTest.zip

XamlTest avatar Feb 18 '24 10:02 XamlTest

It's too scary, I have to add a lot of code

BaY1251 avatar Jun 11 '24 05:06 BaY1251