Bug 57360 - DataTrigger binding not working for bindings to parent Entry with {Binding Text}
Summary: DataTrigger binding not working for bindings to parent Entry with {Binding Text}
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: Macintosh Mac OS
: High minor
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-06-12 00:05 UTC by Mike Norman
Modified: 2017-06-28 14:03 UTC (History)
2 users (show)

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


Attachments
repro project (338.02 KB, application/zip)
2017-06-14 16:23 UTC, Jimmy [MSFT]
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 for Bug 57360 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Mike Norman 2017-06-12 00:05:39 UTC
Repro:
With Xamarin.Forms 2.3.4.247, in the following XAML:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage    xmlns="http://xamarin.com/schemas/2014/forms"
                xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                xmlns:local="clr-namespace:TriggerDemo"
                x:Class="TriggerDemo.TriggerDemoPage">
    <StackLayout VerticalOptions="Center">
        <Label Text="Can you tell me the secret?" VerticalOptions="Center" HorizontalOptions="Center">
            <Label.Triggers>
                <DataTrigger TargetType="Label"
                    Binding="{Binding Source={x:Reference checkEntry},
                                      Path=Text}"
                    Value="The text color is green">
                    <Setter Property="TextColor" Value="Color.Green" />
                </DataTrigger>
            </Label.Triggers>
        </Label>
        <Entry Placeholder="Type the secret here." x:Name="checkEntry" VerticalOptions="Center" HorizontalOptions="Center">
            <Entry.Triggers>
                <DataTrigger TargetType="Entry"
                    Binding="{Binding Source={x:Reference checkEntry},
                                      Path=Text}"
                    Value="The">
                    <Setter Property="TextColor" Value="Red" />
                </DataTrigger>
            </Entry.Triggers>
        </Entry>
    </StackLayout>
</ContentPage>

...replace Binding="{Binding Source={x:Reference checkEntry}, Path=Text}" in the Entry markup with Binding="{Binding Text}".

Expected:
The implicit binding to the parent control works, and the text color changes to red while the trigger condition is met. (For example, as page 867 of Petzold's Creating Mobile Apps with Xamarin.Forms indicates.)

Actual:
Only the explicit binding, where the binding context is specified, works. iOS 7 simulator

Notes:
Changing the XamlCompilationOptions value has no effect
Comment 1 Jimmy [MSFT] 2017-06-14 16:23:39 UTC
Created attachment 22888 [details]
repro project

I can see the issue described using the project I am attaching. I'm confirming the report so we can get a clarification from the engineers whether this is expected behavior or not.