Bug 35533 - Binding to the current source in XAML causes null to be passed to converters multiple times
Summary: Binding to the current source in XAML causes null to be passed to converters ...
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.5.1
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-11-04 09:38 UTC by John Miller [MSFT]
Modified: 2015-11-18 03:19 UTC (History)
4 users (show)

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

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 John Miller [MSFT] 2015-11-04 09:38:27 UTC
**Overview:**

   Something like: 

<Label Text="{Binding ., Converter={StaticResource myConverter}}”/> 

causes the conveters `Convert` function to be called 3 times, the first two times with `null`? 

If you bind like this in code, this behavior does not happen:

.SetBinding(Label.TextProperty, ".", BindingMode.OneWay, new MyConverter());

**Steps to Reproduce:**

   1. Set a breakpoint on line 13 of FullNameConverter. 
   2. Run the attached sample on an iOS simulator

**Actual Results:**

   null is passed twice to the converter before the non-null value is passed. 

**Expected Results:**

   only the non-null value should be passed, calling the converter once. 

**Build Date & Platform:**

   XF 1.5.1
Comment 2 Stephane Delcroix 2015-11-18 03:19:01 UTC
that's normal behavior.

in XAML: we create the label, set the binding (it's applied with null) then we package the label into its parent (and it get its BindingContext)

in code, you're probably doing it the other way, and setting the binding as late as possible