This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.

Bug 22720

Summary: Add support for TargetNullValue and FallbackValue in XAML bindings
Product: Forms Reporter: Jérémie Di Prizio <jeremie.diprizio>
Component: FormsAssignee: Bugzilla <bugzilla>
Severity: enhancement CC: arpitj, bpanjevic, eric.maupin, jason.smith, jemeryh646, luca.masini, nitescua, oansquer, samantha.houts, sas, seth.rosetter, tony
Priority: Normal    
Version: 1.2.2   
Target Milestone: ---   
Hardware: All   
OS: All   
Tags: Is this bug a regression?: ---
Last known good build:

Description Jérémie Di Prizio 2014-09-06 12:15:11 UTC
At the moment, using either TargetNullValue or FallbackValue in a XAML binding raises a TargetInvocationException which leads me to believe that neither of these properties are implemented (seems to be confirmed by your API reference).

Would be great if they were implemented as setting those fallback/replacement values in the view model code is a bit noisy.

For reference here are the MSDN pages of those properties:

Comment 1 Arpit Jha 2014-09-08 05:53:21 UTC
I have checked this issue with some XAML binding and unable to reproduce it.

Could you please provide us sample project/Steps to reproduce ,build and Environment info also ,So that i can able to check at our end.
Comment 2 Bojan Panjevic 2014-12-11 00:08:31 UTC
I'm also able to confirm the issue. Here is a part of the XAML

 <DataTemplate x:Key="ProfileItemTemplate">
            <StackLayout Orientation="Vertical" Padding="10,0,10,0" HorizontalOptions="Fill">
              <Label Text="{Binding Description}" Font="Large" HorizontalOptions="Fill"/>
              <StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand">
                <Entry Text="{Binding Text}" VerticalOptions="Center" WidthRequest="350"
                       IsVisible="{Binding IsTextRequired}" />
                <Switch VerticalOptions="Center"
                  IsVisible="{Binding IsTextRequired, Converter={StaticResource InvertBooleanConverter }}"
                  IsToggled="{Binding IsChecked, TargetNullValue=False}}"/>
Comment 3 Olivier Ansquer 2016-01-22 20:15:09 UTC
These properties are important and it should not be difficult to add. Why so long? Do you have a simple alternative solution?
Comment 4 Jason Smith 2016-03-16 12:34:42 UTC
The request got set to NEEDS INFO somehow (looks like the triager got confused) and the feature request never made it to the dev team. Im digging through the backlog now trying to find everything and just ran across this.

Its now added to the feature board.
Comment 5 Sascha Schwegelbauer 2016-10-02 13:20:06 UTC

-> It's not present in current
Comment 6 Jason Smith 2017-02-14 19:40:19 UTC
This is not on our current roadmap.
Comment 7 JeremyH 2017-02-14 20:19:35 UTC
So after almost 3 years, for such a basic feature:

1. "triager got confused, Its now added to the feature board."

2. "This is not on our current roadmap"

I honestly haven't experienced any library vendor worse than Xamarin.
Comment 8 Olivier Ansquer 2017-02-15 08:12:57 UTC
+1 for JeremyH's answer. This type of response is incomprehensible on such a simple evolution.