maui
maui copied to clipboard
Implicit styling on .NET 8 is being ignored on the page level
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
.Net 8
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
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.
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).
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.
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.
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.
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
It's too scary, I have to add a lot of code