I've noticed these two ways of implementing databinding in winforms.However, I would like to know which one of them is more preferred (In terms of overall performance e.g design time, efficiency? As far as I know, these two are:
BindingSource as BindingSource:
this.textBox1.DataBindings.Add(new Binding("Text", this.myBindingSource, "Augend", true));
Can be easily implemented during design time with the use of properties window of the form and let it auto-generate the code.
Updates the control by using
INotifyPropertyChanged
and simply callingOnPropertyChanged
without strictPropertyName
values (which seems to be a let down for me)
BindingSource as ViewModel:
this.textBox1.DataBindings.Add(new Binding("Text", this.myViewModel, "Augend", true));
Seems to be more work for the setup without the auto-generation and
ProeprtyName
Matching of the ViewModelUpdates the control by using
INotifyPropertyChanged
BUT thePropertyName
should be the same as theProperty
of the object (which somehow gives the feeling of assurance instead of the previous one)
I'm starting to lean more towards BindingSource as ViewModel but I think it's much easier for the control designer of the application if the BindingSource as BindingSource was used. I believe that the control and the binding will be losely coupled. He can change the controls to whatever he wants and just binds the data using its property windows instead of diving into the code and manually change the setup there.