Data Bindings share object state. The main reason for choosing MVVM is the separation of concerns.
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 1.1k
- Avg merge
- 20h 23m
- Merged PRs (30d)
- 103
Description
### .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.
1. `CurrentBehavior()` method - This will bind to the same ViewModel property, but it results in state-sharing
2. `ExpectedBehavior()` 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.
Contributor guide
Assessment
This issue has not been assessed yet.