Bug 27659 - Implicit Style for ContentPage.Style does not work
Summary: Implicit Style for ContentPage.Style does not work
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.4
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-03-04 13:05 UTC by John Miller [MSFT]
Modified: 2016-11-23 23:35 UTC (History)
15 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:


Attachments
Test Sample (4.65 MB, application/zip)
2015-03-25 10:53 UTC, Abhishek
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description John Miller [MSFT] 2015-03-04 13:05:44 UTC
**Overview:**

   Setting an implicit style for the type ContentPage does not work.

**Steps to Reproduce:**

Add a style to a global resource dictionary per documentation here: http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/styles/#Implicit_Styles

<TargetType="ContentPage">
    <Setter Property="BackgroundColor" Value="#ECF6F3" />
</Style>

**Actual Results:**

   The BackgroundColor is not changed.

**Expected Results:**

   The BackgroundColor of all ContentPages should be ECF6F3

**Build Date & Platform:**

   XF 1.3.5

**Additional Information:**

   Workaround is to set a Key for the style and manually assign it to each Page.
Comment 1 Abhishek 2015-03-25 10:53:20 UTC
Created attachment 10498 [details]
Test Sample

I have tried this issue and unable to reproduce the reported behavior at my end.

Steps To Reproduce:
1. Create a Xamarin.Forms (PCL) application.
2. Add two Content page to the solution.
3. Add Tabbed Page and call that content page.
4. Add the code by referring above link to set style for ContentPages.
5.Run the application on Simulator/Emulator/Device.

Screencast: http://www.screencast.com/t/uUHq8GTnveE
IOS Device Log: https://gist.github.com/Abhishekk360/68b183e0bd9570de4e95
IDE Log:https://gist.github.com/Abhishekk360/ce7e60cfffde8f6d16c6

When I set the TargetType="Button" as given in above link then I am able to set the background. But When I set the TargetType="ContentPage" then I couldn't able to set the background. 

Am I following correct steps to reproduce reported behavior?

I am attaching my sample. Please have a look and confirm whether I am following the correct steps to reproduce this issue.

Environment Info:

Xamarin.Forms: 1.4.1.6347-pre2
=== Xamarin Studio ===

Version 5.9 (build 301)
Installation UUID: 93e693b0-b53d-40f4-b29c-b61ff5cbe892
Runtime:
	Mono 4.0.0 ((detached/9e58200)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000106

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.Android ===

Version: 5.1.0.82 (Enterprise Edition)
Android SDK: /Users/xamarin23/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.iOS ===

Version: 8.10.0.156 (Enterprise Edition)
Hash: e18cdfd
Branch: master
Build date: 2015-03-24 20:05:18-0400

=== Xamarin.Mac ===

Version: 2.0.0.156 (Enterprise Edition)

=== Build Information ===

Release ID: 509000301
Git revision: eac5f3400f7693042e03dbdf4687449581ee8000
Build date: 2015-03-24 12:34:18-04
Xamarin addins: fb8773221226b0f920a1038e741081fa9cc6ec97

=== Operating System ===

Mac OS X 10.10.0
Darwin 800BC.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 2 Jon Douglas [MSFT] 2015-08-05 13:25:29 UTC
I have confirmed this bug with a small example:

<Application
	xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="TipCalculator.App">

	<Application.Resources>
		<ResourceDictionary>


            <Style TargetType="ContentPage">
                <Setter Property="BackgroundColor" Value="Green" />
            </Style>

        </ResourceDictionary>
	</Application.Resources>
	
</Application>

Then within any other ContentPage, the BackgroundColor is not inherited and thus I'm confirming this bug.

Xamarin Forms Version: 1.4.4.6392
Comment 3 Jason Smith [MSFT] 2015-12-08 19:08:27 UTC
Implicit styles do not apply to subclasses.
Comment 4 blitzillu 2016-08-31 16:54:03 UTC
@Jason:

Can you explain the reasons for this behavior?

That means that you can't use any implicit styles for a page (always a subclass of ContentPage)? What are other solutions for setting a global background color?
Comment 5 Rodrigo Díaz Concha 2016-11-23 23:35:40 UTC
@blitzillu:

Use the ApplyToDerivedTypes property:

      <Style TargetType="ContentPage"
             ApplyToDerivedTypes="True">
        <Setter Property="Padding" Value="20" />
      </Style>