MVVM accessing Dispatcher silverlight

Topics: Prism v2 - Silverlight 3
Sep 23, 2009 at 6:07 PM

I'm working with prism on a silverlight project and I'm wondering what is the best way to get at the Dispatcher from within a View Model class?

I'm looking for a best practices approach. 

Many thanks,


Sep 23, 2009 at 6:41 PM


I am also looking for the best way as well, but I have been grabbing it in the bootstrapper CreateShell then adding it to my unity containers. I then can resolve it within my VMs.


<font size="3">





Sep 24, 2009 at 12:54 AM

Thanks Marcus, I had a service returning my Dispatcher, but I think I will do what you are doing, then in my ViewModel base class, set it when needed as below.  I was not sure if prism had something built in to access the Dispatcher.

       private Dispatcher _dispatcher;

        protected Dispatcher Dispatcher
                if (this._dispatcher == null)
                    this._dispatcher = ServiceLocator.Current.GetInstance<System.Windows.Threading.Dispatcher>();

                return _dispatcher; 




Sep 24, 2009 at 8:14 AM


Cool if you find a better way let me know.


Sep 24, 2009 at 11:14 AM

It may be helpful for you to look at this post of mine, which shows how I get access to the Dispatcher from my VMs.