-
-
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
Combobox SelectedItem sends extra set value #4461
Comments
The issue goes away if you bind with x:Static like so: <ComboBox Items="{x:Static uimodels:TestModel.SelectableValues}" SelectedItem="{Binding SelectedObject.Value}" /> So the problem is probably in how Items is handled upon being unbound |
I've tried reproducing this but I don't think I have enough information to reproduce. Here's the code I tried to reproduce it with which was adapted from your repro here: https://gist.github.com/grokys/722d90147f8b3a6632d5b1bcb362e074 However, it doesn't cause the crash as the issue says. Could I have a full minimal repro please? |
@grokys My repro is here: https://github.com/Kermalis/AvaloniaRepro4461 |
Intro
I have this model:
And this is the xaml that uses this model
My DataContext has an
ObservableCollection<TestModel>
which holds the models. The control has a ComboBox to select the current TestModel (which is then stored in SelectedObject)The problem
When I run the following code:
OR
I get a crash in SelectedObject.Value.set because the ComboBox tried to set the
Value
property to the first item in the ComboBox despite it no longer being bound. If I do not set Obj to null in TestModel.Dispose(), then there's no crash, but I now have a value I did not select stored in Obj.Value (always the first item in TestModel.SelectableValues)Expected behavior
ComboBox should not set the value since it is now unbound. No other controls are doing it (NumericUpDown, etc) on the same model.
Personally, given how many problems I've encountered with ComboBox, we should just port the ComboBox from WPF at this point since I'm assuming it's way more functional
The text was updated successfully, but these errors were encountered: