This project is read-only.

Why required public setters?

Mar 21, 2014 at 7:02 PM
Is it really necessary for the model property setters to be public? For example in my model I have

public class ParameterValueViewModel : NotifyPropertyChanged {

  private DateTime _Created;
  public DateTime Created {
     get { return _Created; }
     set { SetValueProperty(ref _Created, value, "Created"); }

  private double _DisplayValue;
  public double DisplayValue {
     get { return _DisplayValue; }
     private set { SetValueProperty(ref _DisplayValue, value, "DisplayValue"); }

Pay attention that DisplayValue setter is private. It's supposed to be private because its value is set inside of the model (I omitted that part of the logic for simplicity of the example). Thus, if it's private and I bind a collection of these models to a LineSeries.PointsSource an exception is thrown with a very vague message. I tracked it down to the
                FastProperty fastPropertInfo = new FastProperty(xPropertInfo);
which requires the setter to be public but for what reason?