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

[Bug] Global implicit style for ContentPage not being applied #12350

Open
Cfun1 opened this issue Oct 3, 2020 · 5 comments
Open

[Bug] Global implicit style for ContentPage not being applied #12350

Cfun1 opened this issue Oct 3, 2020 · 5 comments

Comments

@Cfun1
Copy link

Cfun1 commented Oct 3, 2020

Description

Global style for ContentPage is not working at all.

Steps to Reproduce

  1. Sample application based on a Shell, with one or more ShellContent of a ContentPage.
  2. Define a default global style for ContentPage.
   <Application.Resources>
        <ResourceDictionary>
            <Style TargetType="{x:Type ContentPage}">
                <Setter Property="BackgroundColor" Value="Black"/>
            </Style>

            <Style TargetType="{x:Type Label}">
                <Setter Property="TextColor" Value="red"/>
            </Style>
        </ResourceDictionary>
    </Application.Resources>

Expected Behavior

All ContentPage used in ShellContent (in this case) should have the background color black, and all Label used in application should have their text color red.

Actual Behavior

Label style is applied globally, but ContentPage style is not applied at all. (So it is probably not related with #10141)

Note

Global explicit style for ContentPage is not always working.

Basic Information

  • Version with issue: 5.0.0-pre5
  • Last known good version: NA
  • IDE: VS2019
@Cfun1 Cfun1 added s/unverified New report that has yet to be verified t/bug 🐛 labels Oct 3, 2020
@Cfun1 Cfun1 changed the title [Bug] Global style for ContentPage not being applied [Bug] Global implicit style for ContentPage not being applied Oct 3, 2020
@Seuleuzeuh
Copy link

Same issue in the first 5.0 preview

@jsuarezruiz jsuarezruiz removed the s/unverified New report that has yet to be verified label Oct 7, 2020
@jsuarezruiz
Copy link
Contributor

Attached a repro sample:
Issue12350.zip

@Saigronas
Copy link

Saigronas commented Sep 23, 2022

Workaround mentioned in #10179 that works for me:

Add "ApplyToDerivedTypes="True" in style definition, ex:

<Style TargetType="ContentPage" ApplyToDerivedTypes="True">
fix copied from comment #10179 (comment)

@higun295
Copy link

higun295 commented Jun 29, 2023

@Saigronas It works for me. Thanks.

But, why should I add 'ApplyToDerivedTypes' to True ? I didn't understand fully yet..

I also found something. My problem was caused by Android Device's 'dark mode'.
Because of this, implicit global style wasn't working.

As a result, I cleared my problem. Thank you for everyone.

@Lucas-DeLorenzi
Copy link

Hi! I had the same problem, and I found the solution here...

Regarding the question of "why should I set 'ApplyToDerivedTypes' to True?" I believe that any class we create as a ContentPage is actually a derived class. It might be a mistake to think that we have created a ContentPage when, in fact, we are creating a XView that derives from a ContentPage.

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

6 participants