开发者

Why do WPF bindings need getters and setters?

If I have a WPF listbox and I开发者_运维问答 bind its itemssource to a list of objects. If the object members are public but don't have a { get; set; } the binding will fail. Why?


I think what you're really asking is "Why do I have to use properties instead of just fields?" And the answer is that that's just how WPF bindings work. You have to bind to properties on objects. The binding system doesn't look for matching fields.


The binding is looking specifically for Properties, not fields. That's why bindings work on PropertyPath objects.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜