0

When I have a binding to a child property on 2nd or 3rd level, and the child property changes, the view is not updated. E.g.

When property1 changes the view gets no update from Propertychanged.

This is the example object:

{
 public string property1 {get;set;}
 public string property2 {get;set;}
}

When I want the view to get updated, I have to do this:

{
 private string _property1;
 public string property1
   {
     get{
      return _property1;
     }
     set{
      _property1 = value;
      OnPropertyChanged("property1");
     }
   }
}

I have a lot of properties and its very annoying to change every one with that repeating code, so I have a public OnPropertyChanged method and pass null to it, so everything gets changed. It works, but I don't think it's a good and performant solution to tell the view that everything changes when just one property gets changed.

Does anybody know a better solution for that?

Mr.Sheep
  • 311
  • 3
  • 16

1 Answers1

3

You can use PropertyChanged.Fody this will write automatically getters and setters in a class that implements INotifyPropertyChanged.

lema
  • 470
  • 2
  • 9