New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] MultiBinding converter use throwing TargetInvocationException #11058
Comments
Not sure if it's related, but given the following code I'd expect the
It's the 5th call to |
when the binding context is null (the first time the binding is applied), each binding is resolved to null, hence the null array.
I know that the converter is invoked a few extra time, but that's room for enhancement, not a real bug. The expectation of a single convert is too low. At the very best, if the bindings are synchronised (which they aren't), it should be at least 2 (once with a null array, once with the array of populated values). I'll look at providing a perf fix in the coming weeks |
@davidbritch I think I've finished this investigation:
// Return UnsetValue to use the binding FallbackValue
return BindableProperty.UnsetValue;
<MultiBinding Converter="{StaticResource AllTrueConverter}">
<Binding Path="Employee1.IsOver16" />
<Binding Path="Employee1.HasPassedTest" />
<Binding Path="Employee1.IsSuspended"
Converter="{StaticResource InverterConverter}" />
</MultiBinding> doesn't set the adding |
FallbackValue is unit-tested... in code... so there's no need to convert the string literal :( |
and that hidden issue is now fixed |
Description
I wrote MultiBinding demos against 4.7-pre1 and they all made sense and worked. In 4.7-pre4, post MultiBinding overhaul, a number of them no longer work. One of the issues seems to be that
IMultiValueConverter
implementations aren't receiving data.For example, given the following code the
AllTrueConverter
should receive an array of 3 items of data. Instead, the converter is receiving an array of 3null
items.The result is a
TargetInvocationException
with an inner exception ofNullReferenceException
:{System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.Forms.CheckBox.get_IsChecked () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\CheckBox.cs:31
at Xamarin.Forms.CheckBox.ChangeVisualState () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\CheckBox.cs:37
at Xamarin.Forms.CheckBox+<>c.<.cctor>b__33_0 (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00022] in D:\a\1\s\Xamarin.Forms.Core\CheckBox.cs:16
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:463
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397
at Xamarin.Forms.MultiBinding.Apply (System.Object context, Xamarin.Forms.BindableObject targetObject, Xamarin.Forms.BindableProperty targetProperty, System.Boolean fromBindingContextChanged) [0x00162] in D:\a\1\s\Xamarin.Forms.Core\MultiBinding.cs:147
at Xamarin.Forms.BindableObject.SetBinding (Xamarin.Forms.BindableProperty targetProperty, Xamarin.Forms.BindingBase binding, System.Boolean fromStyle) [0x0008a] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:181
at Xamarin.Forms.BindableObject.SetBinding (Xamarin.Forms.BindableProperty targetProperty, Xamarin.Forms.BindingBase binding) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:157
at DataBindingDemos.MultiBindingConverterPage.InitializeComponent () [0x00012] in /Users/davidbritch/repos/xamarin-forms-samples/DataBindingDemos/DataBindingDemos/DataBindingDemos/obj/Debug/netstandard2.0/Views/MultiBindingConverterPage.xaml.g.cs:22
at DataBindingDemos.MultiBindingConverterPage..ctor () [0x00008] in /Users/davidbritch/repos/xamarin-forms-samples/DataBindingDemos/DataBindingDemos/DataBindingDemos/Views/MultiBindingConverterPage.xaml.cs:9
at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:936 }
Steps to Reproduce
Expected Behavior
A page of UI displays.
Actual Behavior
TargetInvocationException
with an inner exception ofNullReferenceException
.Basic Information
Reproduction Link
DataBindingDemos.zip
The text was updated successfully, but these errors were encountered: