Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding and Getters & Setters [duplicate]

Why does public string name {get; set;} work when binding, but public string name; does not? Why is the getter required when they both return the same string?

like image 656
bwoogie Avatar asked Jan 31 '26 10:01

bwoogie


1 Answers

Because you can only bind to public properties in WPF. The following is a field and not a property:

public string name;

The binding engine only looks for properties when the binding expressions are evaluated using reflection at runtime.

like image 160
mm8 Avatar answered Feb 02 '26 23:02

mm8



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!