Implict style for ContentPage not working
See original GitHub issueDescription
Using implicit style with ContentPage as target type seems not to work.
This was an issue in Xamarin.Forms, too. See https://github.com/xamarin/Xamarin.Forms/issues/12350.
Steps to Reproduce
Add an implicit style in Styles.xaml targeting ContentPage. For example:
<Style TargetType="ContentPage">
<Setter Property="BackgroundColor" Value="Red" />
<Setter Property="Opacity" Value="0.5" />
</Style>
Expected outcome: all ContentPages should respect the style above.
Actual outcome: The implicit style seems to be ignored.
Link to public reproduction project repository
https://github.com/Riccardo11/MarketGrowthStrategy
Version with bug
6.0.400
Last version that worked well
Unknown/Other
Affected platforms
iOS Android
Affected platform versions
iOS 16 Android 11
Did you find any workaround?
Adding ApplyToDerivedTypes="True" seems to solve the bug.
Relevant log output
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:10 (1 by maintainers)
Top Results From Across the Web
xaml - Content page property not set with implicit style
1 Answer 1 ... TargetType in style is set to ContextPage but the real type is ChooseProfileView. ... Developers should be aware that...
Read more >Implicit Styles in Xamarin.Forms
An implicit style is one that's used by all controls of the same TargetType, without requiring each control to reference the style.
Read more >How to design efficiently on Xamarin Forms - Implicit Styles
This post is about implementing implicit styles, those that are automatically ... let's create an implicit style inside our ContentPage.
Read more >Working with .NET MAUI Styles - YouTube
In this video you will learn about implicit styles, explicit styles ... in my free time, and not officially affiliated with or endorsed...
Read more >Styles and Resources - Xamarin Forms Guide
Implicit styles do not specify a key when they are defined. The style will be applied automatically to all controls of the specified...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thank you for your answer.
If this is the behavior by design, shouldn’t it be documented? I wasn’t able to find any hint about the solution I proposed inside Microsoft documentation, nor some explicit reference to ContentPage acting like this.
@oliver-ec it’s all about that
ApplyToDerivedTypes="True". Check the workaround in the issue description.The weird thing is that you have to specify that attribute even if you have to set a style specifically for
ContentPageand you don’t care about derived types. Otherwise it doesn’t work.