Bug 51631 - Effect doesn't work with binding
Summary: Effect doesn't work with binding
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Stephane Delcroix
Depends on:
Reported: 2017-01-19 07:07 UTC by AlexvanB
Modified: 2017-06-22 09:52 UTC (History)
5 users (show)

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

Testcase (16.47 KB, application/zip)
2017-02-01 09:25 UTC, AlexvanB

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 AlexvanB 2017-01-19 07:07:47 UTC
Because we have our own fonts and accessibility sizing I made effects to render label text, this works for hard coded text but not for text injected via binding.

        <Label Text="Title" Style="{StaticResource BodyTextStyle}" >
                <local:BodyStyleFontEffect />

Does not work
        <Label Text="{Binding Title}" Style="{StaticResource BodyTextStyle}" >
                <local:BodyStyleFontEffect />
Comment 1 AlexvanB 2017-01-19 09:07:04 UTC
Workaround, in the effect force the property changed 

protected override void OnAttached ()
        var preferredFont = UIFont.GetPreferredFontForTextStyle (new NSString (Constants.FontBodyIOS));
        var fontname = UIAccessibility.IsBoldTextEnabled ? Constants.FontBold : Constants.FontRegular;

        if (Element is Label) {
            var label = Control as UILabel;
            label.Font = UIFont.FromName (fontname, preferredFont.PointSize);

            Element.PropertyChanged += (sender, e) => {
                label.Font = UIFont.FromName (fontname, preferredFont.PointSize);
Comment 2 Stephane Delcroix 2017-01-27 11:30:45 UTC
Could you please attach the simplest possible project triggering this issue so we could investigate ?

Comment 3 AlexvanB 2017-02-01 09:25:24 UTC
Created attachment 19676 [details]
Comment 4 Stephane Delcroix 2017-02-01 11:56:31 UTC
Comment 5 Stephane Delcroix 2017-05-31 09:28:50 UTC
it's not related to Binding, but to timing. changing the Label.Text after a short delay produce the same behavior.
Comment 6 Stephane Delcroix 2017-05-31 09:33:38 UTC
found it.

updating the Text resets text color and font.

Comment 7 Samantha Houts [MSFT] 2017-06-08 17:12:48 UTC
Comment 8 Rui Marinho 2017-06-22 09:52:50 UTC
Should be fixed on 2.3.6-pre1