Bug 41266 - On WinRT and UWP, with two bindings to a property but with different value converters, only one binding is updated
Summary: On WinRT and UWP, with two bindings to a property but with different value co...
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.2.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: E.Z. Hart [MSFT]
Depends on:
Reported: 2016-05-23 18:10 UTC by John Hardman
Modified: 2017-06-20 18:52 UTC (History)
5 users (show)

Tags: ValueConverter WinRT UWP Binding
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:

Description John Hardman 2016-05-23 18:10:27 UTC
Using XF

On WinRT and UWP, with two bindings to a property, but with different value converters used (or with only one of the bindings having a value converter), only one binding is updated when the property changes rather than both updating.

With the following binding and property:

        public static readonly BindableProperty IsToggledProperty
            = BindableProperty.Create(
                typeof (bool),
                typeof (MyAppToggleImageButton),

        public bool IsToggled
                return (bool)GetValue(IsToggledProperty);

                SetValue(IsToggledProperty, value);

And with two images as follows:

        private Image _toggledImage;
        private Image _untoggledImage;

            _toggledImage = new Image { Aspect = Aspect.AspectFit };
            _toggledImage.Source = toggledImageSource;
            _toggledImage.Opacity = 1.0;
            _toggledImage.InputTransparent = true;
            _toggledImage.WidthRequest = 44;

            _untoggledImage = new Image { Aspect = Aspect.AspectFit};
            _untoggledImage.Source = untoggledImageSource;
            _untoggledImage.Opacity = 1.0;
            _untoggledImage.InputTransparent = true;
            _untoggledImage.WidthRequest = 44;

	    // Other code here to place images on page

And bindings as follows:

                Binding toggledBinding = new Binding();
                toggledBinding.Source = this;
                toggledBinding.Path = "IsToggled";
                _toggledImage.SetBinding(Image.IsVisibleProperty, toggledBinding);

                Binding untoggledBinding = new Binding();
                untoggledBinding.Source = this;
                untoggledBinding.Path = "IsToggled";
                untoggledBinding.Converter = NegateBooleanConverter.Instance;
                _untoggledImage.SetBinding(Image.IsVisibleProperty, untoggledBinding);

When IsToggled is changed, only one of the two bindings is updated on WinRT and UWP. On Android and iOS, both bindings are updated, so that which image is visible changes as IsToggled changes on Android and iOS.

On WinRT and UWP, the same, incorrect, behavior is seen even if a different value converter is added to toggledBinding.
However, if the same value converter is used on both bindings, both bindings and images update (although then they are either both visible or both invisible, rather than one being visible at any time, so not what is actually wanted).

The NegateBooleanConverter is as follows:

    public class NegateBooleanConverter : IValueConverter
        public static NegateBooleanConverter Instance = new NegateBooleanConverter();

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            System.Diagnostics.Debug.WriteLine("In NegateBooleanConverter. Input value = {0}, TargetType = {1}", value, targetType );
            if (value is bool)
                return !((bool)value);
            return value;
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            return value;
Comment 1 John Hardman 2016-05-23 18:34:34 UTC
Note that there is an outside chance that https://bugzilla.xamarin.com/show_bug.cgi?id=36097 has some bearing on this, but given that changing the value converter makes a difference it seems unlikely. I mention it for sake of completeness, as my images are in a grid in a viewcell in a listview populated using a data template. However, I don't think that will be the cause.
Comment 2 E.Z. Hart [MSFT] 2016-06-03 18:56:40 UTC
We've been trying to create a reproduction of this issue using the code you supplied (and filling in the blanks as best we could), but so far everything seems to be working correctly. Could you provide a reproduction project? Perhaps there's a detail we're missing.

XF Team
Comment 3 John Hardman 2016-10-03 16:42:13 UTC
I will re-test this one after 44680 is fixed. I suspect that 41266 may be a non-issue, looking like a problem because of 44680 (and to a lesser extent, possibly 44981).
Comment 4 Rui Marinho 2017-06-20 18:52:32 UTC
Unfortunately, we’re unable to reproduce this report. If this issue is still occurring for you, please reopen this issue and attach a reproduction to the bug by starting with a clean Xamarin.Forms project adding just the code necessary to demonstrate the issue. 
Here are some reproduction best practices: https://gist.github.com/jassmith/92405c300e54a01dcc6d