Bug 60459 - Setter not hit for BindableProperty if value set from XAML
Summary: Setter not hit for BindableProperty if value set from XAML
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.4.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-10-31 20:42 UTC by Harikrishnan
Modified: 2017-11-01 07:13 UTC (History)
6 users (show)

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


Attachments
Sample replicating the reported issue (304.06 KB, application/x-zip-compressed)
2017-10-31 20:42 UTC, Harikrishnan
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:
RESOLVED ANSWERED

Description Harikrishnan 2017-10-31 20:42:55 UTC
Created attachment 25523 [details]
Sample replicating the reported issue

Hi Team,

The setter of a property of my CustomView is not hit if i assign a value to that property from the XAML.

My requirement is to assign value to a bool field in the setter of the property, so that based on that condition, i can perform some actions in the code. Please refer the attached sample for replication procedure.

I have a Custom View with a BindableProperty. Inside the setter of the property, i have set value to a bool field. Based on this value of the bool field i have performed code flow in my app. However since the setter of the property is not hit, i am ending up with wrong values for the bool property due to which my code flow diverges.
Comment 1 Paul DiPietro [MSFT] 2017-10-31 21:57:34 UTC
Setting the value in XAML doesn't invoke the property's setter. Refer to this SO answer for reference:

https://stackoverflow.com/questions/39491978/ignore-the-binding-initialization/39506043#39506043

"The property, and the property accessors, are only meant to be invoked when accessing the property by code. C# code."