我注意到了在winforms.However中实现数据库的这两种方法,我想知道哪一种方法更可取(比如总体性能,比如设计时间、效率?)据我所知,这两人是:
BindingSource as BindingSource:
this.textBox1.DataBindings.Add(new Binding("Text", this.myBindingSource, "Augend", true));
INotifyPropertyChanged更新控件,只需在没有严格PropertyName值的情况下调用OnPropertyChanged (这似乎让我失望了)BindingSource as ViewModel:
this.textBox1.DataBindings.Add(new Binding("Text", this.myViewModel, "Augend", true));
ProeprtyName匹配的ViewModel设置,似乎要做更多的工作。INotifyPropertyChanged 更新控件,但是 PropertyName应该与对象的Property相同(这在某种程度上提供了保证的感觉,而不是前一个)我开始更倾向于BindingSource作为ViewModel,但我认为如果使用BindingSource as BindingSource,对应用程序的控制设计人员来说要容易得多。我相信控制和约束将是不紧密耦合的。他可以将控件更改为他想要的任何东西,只需使用其属性窗口来绑定数据,而不是跳转到代码中,并手动更改那里的设置。
发布于 2015-12-14 20:07:07
但是,我想知道哪一个更好(在总体性能方面,比如设计时间,效率?)
很快,就没有首选的了。
BindingSource或类似的中介之外,没有其他选择。BindingSource本身不过是一个数据源适配器,它在设计时绑定到类型的(或小型数据模型),并在运行时绑定到真正的实例。https://stackoverflow.com/questions/34259790
复制相似问题