Bug 42447 - Application-wide Styles are not applied to modal pages in UWP, Windows and WP8.1
Summary: Application-wide Styles are not applied to modal pages in UWP, Windows and WP8.1
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-07-09 00:11 UTC by Mike Smith
Modified: 2017-12-14 10:19 UTC (History)
13 users (show)

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


Attachments
Bug and test project descriptions (510.35 KB, application/pdf)
2016-07-09 00:11 UTC, Mike Smith
Details
Test project demonstrating the issue (531.01 KB, application/x-zip-compressed)
2016-07-09 00:13 UTC, Mike Smith
Details
Test project demonstrating that a native UWP application does not demonstrate the issue (109.42 KB, application/x-zip-compressed)
2016-07-09 00:14 UTC, Mike Smith
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 for Bug 42447 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Mike Smith 2016-07-09 00:11:31 UTC
Created attachment 16618 [details]
Bug and test project descriptions

=== Overview ===
In a Xamarin.Forms project, application-wide Styles are not being picked up on certain pages of UWP, Windows 8.1 and Windows Phone 8.1 projects.   The Styles are being applied correctly for all pages of iOS and Android projects.  The Styles are also correctly applied to the main (root) page of UWP, Windows 8.1 and Windows Phone 8.1 projects.  They are not being applied to subsequent pages navigated to from the main page in UWP, Windows 8.1 and Windows Phone 8.1 projects.

=== Steps to Reproduce  ===
	1) Create a Xamarin.Forms PCL project.
	2) Add an Application.Resources ResourceDictionary with one or more Styles having no key to the App.xaml file, creating an application-wide ResourceDictionary:

	  <Application.Resources>
	    <ResourceDictionary>
	      <Style TargetType="Button">
	          <Setter Property="BorderColor" Value="Red"/>
	          <Setter Property="TextColor"  Value="Red"/>
	      </Style>
	    </ResourceDictionary>
	  </Application.Resources>
	
	3) Define multiple pages in the application each using a control with the TargetType of the Style
	4) Add a page navigation to the main (root) page of the application to navigate to a subsequent page.
	5) Run the application and navigate to a subsequent page.
	
=== Expected Behavior ===
The application-wide Style should be applied to all controls of the TargetType on all pages of the all five application types.

=== Actual Behavior ===
After navigating to the subsequent page, in the UWP, Windows 8.1 and Windows Phone 8.1 applications, the Style will not be applied to the controls with indicated TargetType.  In the iOS and Android applications, the Styles will be correctly applied.  The Styles are also correctly applied to the root page of all five applications (iOS, Android, UWP, Windows 8.1 and Windows Phone 8.1).

=== Build Information ===
Build date 2016-07-08 on Windows 10, Visual Studio Enterprise 2015 Version 14.0.25421.03 Update 3, Xamarin.Forms 2.3.0.107

== Additional Info ===
A Xamarin.Forms test project demonstrating the issue is attached (TestRD.zip), along with more explanatory detail in a PDF file (Case 356930 Bug Report.PDF).  This test was built with version 2.3.0.107 of Xamarin.Forms.  Another test project is attached (TestUWP.zip) that demonstrates the same functionality in a native UWP (non-Xamarin.Forms) project.  This project works as expected and the application-wide Styles are properly applied to all controls on all pages of the application.

A work-around has been identified - Add the following line in the code-behind for each subsequent (non-main or non-root) page of the application in the PCL project, just after the line that calls InitializeComponent:

Resources = App.Current.Resources;

With this the Styles will be correctly applied to the TargetType controls on that page.
Comment 1 Mike Smith 2016-07-09 00:13:35 UTC
Created attachment 16619 [details]
Test project demonstrating the issue
Comment 2 Mike Smith 2016-07-09 00:14:18 UTC
Created attachment 16620 [details]
Test project demonstrating that a native UWP application does not demonstrate the issue
Comment 3 Thomas Hiilbig Pedersen 2017-01-11 14:34:13 UTC
This is still the case in version 2.3.3 of Xamarin.Forms
Comment 4 Vladislav Kosev 2017-01-30 14:09:59 UTC
The styles are not working for modal pages only.
Comment 5 Jimmy [MSFT] 2017-02-06 20:01:51 UTC
I am still seeing this issue with Forms 2.3.3.180 using the project in comment 1. This is happening with pages pushed modally only so I've changed the report title to better reflect the issue.

However the issue appears to be fixed in Forms 2.3.4.184-pre1 as I can no longer reproduce it after updating the same project to the newer version.
Comment 6 FieldstrikeMobile 2017-12-14 10:19:05 UTC
seeing this issue in 2.4.0.75863