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...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.3.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Stephane Delcroix
URL:
Depends on:
Blocks:
 
Reported: 2017-03-31 13:14 UTC by Björn Bentmar
Modified: 2017-04-11 15:58 UTC (History)
6 users (show)

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


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

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

#SYSTEM
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   4.3.0.795 (aece090)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

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

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

#EXPECTED RESULT
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.

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

#THOUGHTS
-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.

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