Bug 25638 - Unable to use Style Setters for BindableProperties that have defaultValueCreator
Summary: Unable to use Style Setters for BindableProperties that have defaultValueCreator
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 1.3.0
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 25641 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-12-29 12:25 UTC by jruskin
Modified: 2015-01-27 12:49 UTC (History)
8 users (show)

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


Attachments
Repro project (5.49 MB, application/octet-stream)
2014-12-29 12:25 UTC, jruskin
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:
VERIFIED FIXED

Description jruskin 2014-12-29 12:25:03 UTC
Created attachment 9200 [details]
Repro project

Style setters are not being applied to BindableProperties that have a defaultValueCreator set.

I believe this is what's happening
1) BindableObject.BindablePropertyContext is created from the default value creator in BindableObject.GetContextOrCreate without IsSetFromStyle attribute set.
2) Style tries to apply the value from it's setter
3) SetValue(BindableObject, object, bool, bool) checks whether there is a BindableObject.BindablePropertyContext (there is from (1) above) and whether it has the IsSetFromStyle attribute set (it doesn't)
4) Since the value is being set from a style on a context that doesn't have the correct attribute, the value isn't set.

(4) makes sense in most cases, you don't want to overwrite a value that was manually set with a value from a style.  It just doesn't work in this case when the only value that was set is the default value.
Comment 1 Cody Beyer (MSFT) 2014-12-30 23:03:08 UTC
*** Bug 25641 has been marked as a duplicate of this bug. ***
Comment 2 Udham Singh 2014-12-31 13:15:38 UTC
I have checked this issue with the help of sample app attached in bug description and observed that if we change Change font size and TextColor declaration in XAML files then Font size remains the same, regardless of value set in XAML. Only TextColor is changed as per the value set in XAML.

Screencast : http://www.screencast.com/t/owZAhvYuuoF

Font size of text should be changed as per the value set in XAML. Hence marking this issue as confirmed. 

Environment Info :

Xamarin.Forms 1.3.0.6292

Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.50938

Xamarin   3.9.221.0 (a6d269d)
Comment 3 Jason Smith [MSFT] 2015-01-18 05:29:46 UTC
Resolved in 1.3.2-pre1
Comment 4 Ram Chandra 2015-01-23 03:39:51 UTC
I have checked this issue with following builds:

Xamarin.Forms.1.3.2.6299-pre1
Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641
Installed Version: Professional
Xamarin   3.9.236.0 (d6a2cae)
Xamarin.Android   4.20.0.34 (49a04b966feb40dfdba49d57ba16249b66d606a6)
Xamarin.iOS   8.6.0.0 (eb24bdcf5cba2c12b673a07e0a8cce368b9563b3)

When I deployed the attach project and change the style (FontSize,FontAttributes,FontColor) I observed that changes are applied to the BindableProperties.

Screencast: http://www.screencast.com/t/9MT7rkA6J

This issue has been fixed. Hence I am closing this issue.