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

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

Repro project (5.49 MB, application/octet-stream)
2014-12-29 12:25 UTC, jruskin

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 :


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

Xamarin (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:

Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641
Installed Version: Professional
Xamarin (d6a2cae)
Xamarin.Android (49a04b966feb40dfdba49d57ba16249b66d606a6)
Xamarin.iOS (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.

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