-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Regression in 11.1: MultiValueConverter returning BindingNotification throws InvalidCastException #16070
Comments
Definitely looks like a regression introduced by the binding system refactor, will investigate. Not sure if this is a showstopper and needs to be fixed for 11.1.0 or whether it can wait for 11.1.1 though. |
Assuming you mean 11.1.0 and 11.1.1? For me, I don't use the |
Yeah sorry, edited. I'll take a look and see how hard the fix is before we decide if it'll be in 11.1.0. It definitely feels like less of a showstopper than #16071 though. |
I've confirmed that this issue is fixed for me in 11.1.0-RC2. |
Describe the bug
In my application I have several
IMultiValueConverter
s that return aBindingNotification
when values can't be converted. The documentation suggests this is a best practice.With 11.0.10 I have no issues, however when I tried 11.1.0-rc1, I started to get
InvalidCastException
s like the following when navigating through the application:System.InvalidCastException: Unable to cast object of type 'MultiBindingBug.ViewModels.MainWindowViewModel' to type 'MultiBindingBug.ViewModels.MultiConverterViewModel'.
In the debugger, stepping up through the stack, I see that in
PropertyInfoAccessorFactory.SendCurrentValue
a different exception is being caught:System.InvalidCastException: Unable to cast object of type 'Avalonia.Data.BindingNotification' to type 'System.String'.
This is what lead me to the conclusion that the problem was with the converter returning a
BindingNotification
.To Reproduce
In my application, the exception occurs when navigating between views and seems to be triggered by changes in DataContext. I have tried to create a minimal repro:
MainWindow.xaml
HomeView.xaml
MultiConverter.xaml
MainWindowViewModel.cs
HomeViewModel.cs
MultiConverterViewModel.cs
MultiValueConverter.cs
Steps to reproduce:
HomeView
is displayed.MultiConverterView
.Expected behavior
No exception is thrown. (If I'm doing something wrong in my
MultiValueConverter
please advise.)Avalonia version
11.1.0-rc1
OS
Windows
Additional context
Workarounds:
MultiValueConverter.cs
to returnnull
instead of aBindingNotification
The text was updated successfully, but these errors were encountered: