0

Say I have description property in one class:

public string Description
{
    get
    {
        return _description;
    }

    set
    {
        _description = value;
        RaisePropertyChanged("Description");
    }
}

I would like to monitor the change in these value in some other type. How do I wire up?

Anatoliy Nikolaev
  • 22,370
  • 15
  • 69
  • 68
shahul hameed
  • 151
  • 2
  • 16

1 Answers1

2

You can subscribe the event PropertyChanged.

myModel.PropertyChanged+=(s,e)=>{ /* your handler here */};

as the @stijn comment point, unsubscribing can be required if the model became unused to avoid memory leaks.

Felice Pollano
  • 32,832
  • 9
  • 75
  • 115
  • 1
    it's worth mentioning unsubscribing might be needed in some cases: http://stackoverflow.com/questions/12133551/c-sharp-events-memory-leak – stijn Sep 06 '13 at 05:59