Bug 34894 - Trigger isn't applied when using complex path and part of the Path is "null"
Summary: Trigger isn't applied when using complex path and part of the Path is "null"
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.5.2
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-10-15 05:09 UTC by FieldstrikeMobile
Modified: 2015-11-20 06:03 UTC (History)
4 users (show)

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

example (283.27 KB, application/octet-stream)
2015-10-15 12:23 UTC, FieldstrikeMobile

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:

Description FieldstrikeMobile 2015-10-15 05:09:53 UTC
Here is my view with a trigger:

      <Image Grid.Column="3" Grid.Row="1" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Source="Cut.png">
          <DataTrigger TargetType="Image" Binding="{Binding SelectedDay.SelectedDiaryItem, Converter={StaticResource NullToFalseConverter}}" Value="False">
            <Setter Property="Opacity" Value="0.4"/>

`SelectedDay` is initially "null" until the user selects a day.. I am sure this is where the error is.

My converter is:

        public object Convert(object value, Type targetType, object parameter,
            System.Globalization.CultureInfo culture)
            return value is string ? !string.IsNullOrEmpty(value.ToString()) : value != null;

and eventho this returns false... the expected value in the `DataTrigger` the `Setter` is not applied..

My guess... Someone isn't checking that objects in complex paths aren't null in the `DataTrigger` the exception is being caught and datatrigger returning the incorrect value
Comment 1 FieldstrikeMobile 2015-10-15 05:12:35 UTC
In addition to this to further prove my theory.

After selecting a day i.e. `SelectedDay` is no longer null but.. `SelectedDiaryItem` is now null. meaning the converter returns `false` (the expected value same as before, but now where `SelectedDay` is set, i.e. no "object reference not set error").

The setter is now applied
Comment 2 FieldstrikeMobile 2015-10-15 05:46:23 UTC
only tested on `android` so far
Comment 3 Stephane Delcroix 2015-10-15 11:48:31 UTC
Could you please share a test project reproducing this problem so we can look at it ?

Warm thanks,

the XF team
Comment 4 FieldstrikeMobile 2015-10-15 12:23:12 UTC
Created attachment 13345 [details]
Comment 5 FieldstrikeMobile 2015-10-15 12:24:24 UTC
looking at this it might be by design rather than a bug (I worked this out as I was making the example) but I will let you decided that.
Comment 6 FieldstrikeMobile 2015-11-20 06:03:09 UTC
I guess this is by design rather than a bug. Resolving as invalid