using System; using System.Linq.Expressions; using System.Threading; using GalaSoft.MvvmLight; namespace MahTweets.Core { public class MahViewModelBase : ViewModelBase { private readonly SynchronizationContext _syncContext; public MahViewModelBase() { _syncContext = SynchronizationContext.Current; } protected override void RaisePropertyChanged(string propertyName) { _syncContext.Post(s => base.RaisePropertyChanged(propertyName), null); } /// /// Notifies subscribers of the property change. /// /// The type of the property. /// The property expression. protected virtual void RaisePropertyChanged(Expression> property) { var memberExpression = property.Body as MemberExpression; if (memberExpression != null) { _syncContext.Post(s => base.RaisePropertyChanged(memberExpression.Member.Name), null); } } } }