Open egvijayanand opened 1 month ago
8.0.303
Not tested/verified
No, I haven't tried in other versions.
Data Bindings share object state. The main reason for choosing MVVM is the separation of concerns.
A ViewModel property can be bound to any # of controls, the underlying binding engine should ensure that the bound controls don't share state.
Whereas the WinForms binding engine shares state.
The binding logic works fine on all other UI frameworks where it's tested (.NET MAUI, WPF, Xamarin.Forms).
This needs to be addressed.
Will upload the sample project to my GitHub repo and share the URL to clone.
Once cloned, have a look at the MainForm, hosting 2 ComboBox controls and both are data bound.
Then go to the MainForm.cs, and in the constructor, there will be two methods for the data binding configuration.
CurrentBehavior()
ExpectedBehavior()
Comment the first method and uncomment the second method to know the difference.
Build and run the app with data bindings in different configurations.
To convey the issue, have created two different properties in ViewModel, and bound them to those two controls. This is an overhead.
Here's the sample project to simulate this issue:
https://github.com/egvijayanand/winforms-issue-11722
In the current behavior, any change in one ComboBox reflects on the other.
@KlausLoeffelmann will be interest in feedback around databinding.
.NET version
8.0.303
Did it work in .NET Framework?
Not tested/verified
Did it work in any of the earlier releases of .NET Core or .NET 5+?
No, I haven't tried in other versions.
Issue description
Data Bindings share object state. The main reason for choosing MVVM is the separation of concerns.
A ViewModel property can be bound to any # of controls, the underlying binding engine should ensure that the bound controls don't share state.
Whereas the WinForms binding engine shares state.
The binding logic works fine on all other UI frameworks where it's tested (.NET MAUI, WPF, Xamarin.Forms).
This needs to be addressed.
Steps to reproduce
Will upload the sample project to my GitHub repo and share the URL to clone.
Once cloned, have a look at the MainForm, hosting 2 ComboBox controls and both are data bound.
Then go to the MainForm.cs, and in the constructor, there will be two methods for the data binding configuration.
CurrentBehavior()
method - This will bind to the same ViewModel property, but it results in state-sharingExpectedBehavior()
method - This will bind to the different ViewModel properties so it works. Ideally, the first option should behave like this.Comment the first method and uncomment the second method to know the difference.
Build and run the app with data bindings in different configurations.
To convey the issue, have created two different properties in ViewModel, and bound them to those two controls. This is an overhead.