5

I'm using MVVM Light in a Windows Phone Silverlight application.

I don't really get how RaisePropertyChanged should works; Let me explain, in code like this

private Recipe _selectedRecipe;

public Recipe SelectedRecipe
{
    get
    {
        return this._selectedRecipe;
    }
    set
    {
        this._selectedRecipe = value;
        RaisePropertyChanged("SelectedRecipe");
    }
}

What should happen when RaisePropertyChanged("SelectedRecipe") is called?

I expect the call to a new method with my code to execute, or something like that, but i can't be able to find something similar in (the few) examples i found. So, how it works?

maxdelia
  • 858
  • 2
  • 14
  • 35

1 Answers1

4

The InotifyPropertyChanged event is important for data binding in Silverlight, and the RaisePropertyChanged method provided as part of the MVVM-Light toolkit is a helper to raise the event if anyone is listening out for it.

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
  • Thank you for your answer! How can i implement a listener for these events? – maxdelia Jun 12 '12 at 20:08
  • 1
    When you use `{Binding SelectedRecipe}` - here is your listener is implemented for `SelectedRecipe` property changes by Silverlight himself – Ku6opr Jun 12 '12 at 20:26
  • Ok but where can i write my code to execute when RaisePropertyChanged() is called? – maxdelia Jun 13 '12 at 10:42
  • 2
    Oh God. I'm dumb. RaisePropertyChanged() only serves to update the binded elements in the view? O_O – maxdelia Jun 13 '12 at 11:22