7 thoughts on “Provider Based Commands

  1. joshyjf says:

    thanks for xplaining stuff..Toastmasters is indeed looking helpful :)!

  2. nnish says:

    OK I am not asking for warranty. But here I am stuck a strange problem.

    In your RaisePropertyChanged method of BindableObject class – MemberExpression is always null and hence property changed never fires.

    I am talking about this piece of code(the case fails):
    var memberExpression = property.Body as MemberExpression;
    if (memberExpression != null)

    I changed the method signature like this:

    RaisePropertyChanged(Expression<Func> propertyExpression)

    and it worked! Do you know why?

    Here is the full method that I am using:

    /// Raises the property changed
    /// property
    protected void RaisePropertyChanged(Expression<Func> propertyExpression)
    if (PropertyChanged == null)

    var body = propertyExpression.Body as MemberExpression;
    if (body != null)
    var property = body.Member as PropertyInfo;
    if (property != null)
    PropertyChanged(this, new PropertyChangedEventArgs(property.Name));

    Thank you for an awesome article. I have fallen in love with your MVVM framework and I am using them in every project of mine!

    • brettedotnet says:

      Interesting find. However I am unable to reproduce this locally. It seems to be working for me. Could you send me a sample view model that has the issue? Perhaps it has something to do with the expression you are passing to the call to RaisePropertyChanged. Here is an example of something that works for me.

       public string Title
      	        get { return mTitle; }
                      mTitle = value;
                      RaisePropertyChanged((x) => Title);
  3. nnish says:

    Sent the project to your email. Let me know if you find the bug.

    • brettedotnet says:

      Nish thanks for pointing this out.

      It turns out that lamdas on value types using the Action delegate as I had it set up, are converted to UnaryExpression objects. And of course I was attempting to down cast to a MemberExpression. Your changes are the way to go. I have uploaded the modified source code. Thanks very much for pointing this out.

  4. zackpudil says:

    Great upload! Good Job, sir!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: