-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
Original Case
In our Android app we are using a custom control which displays a dropdownlist based on an enum. The user can select an entry to change the value. The value is bound via a TwoWay Multibinding to a property (typed Enum) in the viewmodel.
The value can also be reseted by a button to the inital value.
In Xamarin this worked without a problem. After merging to MAUI we observed, that reseting the value after the user changed it manually did not work anymore.
Demo
I stripped this case down as much as possible to demonstrate in the demo project.
In the project is a simple page backed by a viewmodel with a property (type "int") and OnPropertyChanged events. The Ui features two Entry controls which are bound to the viewmodel property. One entry control uses a simple "Binding", the other a "MultiBinding" with a MultiValueConverter. Also there are buttons to change the value of the property or directly the Entry.Text fields (simulate user changes from a dropdown selection).
After setting the text value on the Entry with MultiBinding, further changes to the property are not update in the ui anymore.
With a simple Binding this case works as expected.
Further observations
I traced the problem down to the execution of the MultiValueConverter.ConvertBack Method. After this is called, the ui updates are broken, though the value is correctly set in the property.
If the property is of type "string" instead of "int", the MultiValueConverter.ConvertBack Method is not called, and all works as expected.
Steps to Reproduce
- Open the linked demo app and deploy it
- Use Buttons "Set Property" to change the value of the property. This will update the Ui accordingly via the bindings.
- Use Button "Set Control (Binding)" to change the value directly in Entry.Text field. This will update the property accordingly via the bindings and also the Ui for the MultiBinding Entry control.
- Use Buttons "Set Property" again to change the value of the property. This will update the Ui accordingly via the bindings.
- Use Button "Set Control (MultiBinding)" to change the value directly in Entry.Text field. This will update the property accordingly via the bindings and also the Ui for the Binding Entry control.
- Use Buttons "Set Property" again to change the value of the property. This will only update the Ui for the Binding Entry control. The MultiBinding Entry control does not get updated anymore.
Bildschirmaufnahme.2024-09-27.153050.mp4
Link to public reproduction project repository
https://github.com/AlvinSch/Demo-Maui-Multibinding
Version with bug
8.0.91 SR9.1
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows, I was not able test on other platforms
Affected platform versions
Android 10, Windows 11
Did you find any workaround?
no
Relevant log output
none