1

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?

2

2 Answers 2

8

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.

Sign up to request clarification or add additional context in comments.

Comments

4

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.