A really simple ViewModel base class with strongly-typed INotifyPropertyChanged

Posted by Daniel Cazzulino on ASP.net Weblogs See other posts from ASP.net Weblogs or by Daniel Cazzulino
Published on Fri, 14 May 2010 12:03:45 GMT Indexed on 2010/05/14 12:04 UTC
Read the original article Hit count: 433

Filed under:
|

I have already written about other alternative ways of implementing INotifyPropertyChanged, as well as augment your view models with a bit of automatic code generation for the same purpose. But for some co-workers, either one seemed a bit too much :o).

So, back on the drawing board, we came up with the following view model authoring experience:

public class MyViewModel : ViewModel, IExplicitInterface
{
    private int value;

    public int Value
    {
        get { return value; }
        set { this.value = value; RaiseChanged(() => this.Value); }
    }

    double IExplicitInterface.DoubleValue
    {
        get { return value; }
        set { this.value = (int)value; RaiseChanged(() => ((IExplicitInterface)this).DoubleValue); }
    }
}
...

Read full article

© ASP.net Weblogs or respective owner

Related posts about .NET

Related posts about All Technology