Sending to UI thread still required when using MVVM Light?

I hope this is not a too stupid question: I just started using MVVM light (I still love it!). In "before time" (i.e. Before using MVVML), I had to send any code that got into the property setting tool in which the INotifyPropertyChanged event was added.

For me (wrong?) It was believed that the requirement would disappear when using MVVMlight.

I still have to use it, right? My experiments tell me a resounding yes.

So this is the really stupid part - since there is a requirement to initialize the dispatcherhelper MVVML class somewhere, where I assume that it saves the UI thread, why not call RaisePropertyChanged in Dispatch automatically? Seems to be a common thing?

Not criticism in itself, but rather "how this does not happen" :-)

Edit (copied from author comment)

FWIW, I did this:

public class QViewModelBase : ViewModelBase { 
    protected override void RaisePropertyChanged(string propertyName) { 
        DispatcherHelper.CheckBeginInvokeOnUI( () => base.RaisePropertyChanged(propertyName)); 
    } 
    protected override void RaisePropertyChanged<T>(string propertyName, T oldValue, T newValue, bool broadcast) { 
        DispatcherHelper.CheckBeginInvokeOnUI( () => base.RaisePropertyChanged<T>(propertyName, oldValue, newValue, broadcast)); 
    } 
}
+5
source share
2 answers

Please refer to my answer here: Thread safe, Silverlight

I highly recommend what you offer.

+1
source

IMO you do not need to send at all! Only operations on the ObservableCollection should be sent.

: ViewModel

+1

All Articles