Bug 54334 - Styles will override properties on UI-Elements when changing resource dictionaries
Summary: Styles will override properties on UI-Elements when changing resource diction...
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.3.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Stephane Delcroix
Depends on:
Reported: 2017-03-31 13:14 UTC by Björn Bentmar
Modified: 2017-04-11 15:58 UTC (History)
6 users (show)

See Also:
Is this bug a regression?: Yes
Last known good build: 2.3.4 pre 2 ac

repro-project (195.57 KB, application/zip)
2017-03-31 13:14 UTC, Björn Bentmar

Description Björn Bentmar 2017-03-31 13:14:49 UTC
Created attachment 21104 [details]

Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01586

Mono Debugging for Visual Studio   Mono.Debugging.VisualStudio
Support for debugging Mono processes with Visual Studio.

Xamarin (aece090)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android (3a62f1e)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS (a05f40e)
Visual Studio extension to enable development for Xamarin.iOS.

CHanging resourcedictinary for App.Current.Resources styles should not override properties set on UI-elements (a labels textcolor i.e). If the Labels textcolor is set to Black in code, styles for a label with setters for TextColor should not override it.

The style-properties will override the properties set in code for the specific UI-element

-If you set your apps resourcedictionary after the initialisation of mainpage it works as it should, but will stop 
 working when you push a new page (this goes for every page instantiated after resources has been set)

-This is a regression, this bug came in 2.3.4 pre 3, it was working fine in pre 2

-I have only tested on android

-I think this PR is the cause to this bug (ontroduced in pre 3) https://github.com/xamarin/Xamarin.Forms/pull/737

-If its unclear what i mean just try the repro-project, it will make sense

Thank you!
Comment 1 Paul DiPietro [MSFT] 2017-03-31 17:21:47 UTC
It looks like the behavior is showing in pre6 as well.
Comment 2 Stephane Delcroix 2017-04-03 09:22:15 UTC
Please note that declaring ResourceDictionaries as Application content is wrong. Application expect a Page as Content. Everything else is ignored, even if the objects are created. This works right now because the assignment test is done after the object creation, BUT THAT IS NOT GUARANTEED TO WORK IN THE FUTURE.

What you want is probably creating ResourcesDictionaries as separate Xaml roots (in separate files) and use those.
Comment 3 Björn Bentmar 2017-04-03 09:25:54 UTC
The current solution i have today is actually what you describe. I just made the repo very simple. but the result is the same in both scenarios.
Comment 4 Rui Marinho 2017-04-06 21:19:41 UTC
Should be fixed on 2.3.4-sr1 or 2.3.5-pre1
Comment 5 tsauder91 2017-04-11 15:12:04 UTC
I just updated my project to the stable release of 2.3.4 and this still seems to be an issue.
Comment 6 Björn Bentmar 2017-04-11 15:13:22 UTC
Thats because the fix is not included in 2.3.4...
Comment 7 tsauder91 2017-04-11 15:58:17 UTC
Oops miss read the comment above my last sorry.

Notice (2018-05-21): bugzilla.xamarin.com will be switching to read-only mode on Thursday, 2018-05-25 22:00 UTC.

Please join us on Visual Studio Developer Community and GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs and copy them to the new locations as needed for follow-up. The See Also field on each Bugzilla bug will be updated with a link to its new location when applicable.

After Bugzilla is read-only, if you have new information to add for a bug that does not yet have a matching issue on Developer Community or GitHub, you can create a follow-up issue in the new location. Copy and paste the title and description from this bug, and then add your new details. You can get a pre-formatted version of the title and description here:

In special cases you might also want the comments:

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.

Note You need to log in before you can comment on or make changes to this bug.