I have a class that I am binding to my view model. It is basically a struct full of displayable strings for the UI:
class DisplayVO
{
public string Title { get; set; }
public string Description { get; set; }
// ... about a dozen more properties
}
Basically the DisplayVO wraps a bunch of properties that are bound to the UI. This works until one portion of the UI modifies a property (e.g. the user can edit the Description) so I want to update the UI with the new modifications.
So what I would normally do is implement the INotifyPropertyChanged interface and override each set method to broadcast PropertyChanged(this, new PropertyChangedEventArgs(info));
I’m feeling lazy – is there a way to have this done for all members of the class? In Flex I could do:
[Bindable]
public class DisplayVO
{
private var Title:String;
private var Description:String;
}
and magically all of the properties of DisplayVO would be wrapped to automatically broadcast changes without me having to write all of the boilerplate. Is there an equivalent for C# and WPF?
You should check out NotifyPropertyWeaver http://github.com/SimonCropp/NotifyPropertyWeaver it runs a post build task which does exactly what you are after.