c# - 为什么我不能数据绑定(bind)到一个字段?

标签 c# data-binding

我刚刚(艰难地)了解到数据绑定(bind)不适用于字段。考虑到自动属性的简单性,这不是问题,但我想知道为什么会这样。谁能解释一下?

最佳答案

我找到了一个很好的解释here :

... because public fields are not a recommended practice. While they maybe convenient for quick and dirty code, they do not version. Using properties instead allows you to change the access logic, and data storage behind the covers, as well as add validation logic when a value is assigned. Furthermore, accessing properties feels pretty much the same, and do not have any performance overhead.

关于c# - 为什么我不能数据绑定(bind)到一个字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/483148/

相关文章:

javascript - 多事件绑定(bind)快捷方式

jquery - Angular2如何获取所有选中的复选框

c# - 使用 iTextSharp 从 pdf 中提取图像及其名称

c# - linq .Value 可空对象必须有一个值。如何跳过?

c# - 在整个代码库上重构 "using"指令?

c# - 为什么我的 UserControl 绑定(bind)不起作用?

javascript - 了解 Angular 数据绑定(bind)

android - MvvmCross Android ImageView绑定(bind)图片src

c# - WebView2 DevToolsProtocolEvent 未引发

c# - 底层连接已关闭 : An unexpected error occurred