wp7 DispatcherHelper.Initialize(); template inclusion?

Feb 27, 2012 at 5:47 PM

Thank you for MVVM light tool kit and the awesome documentation.

Recently I banged my head severely for hours on a Null exception from this:

            Messenger.Default.Register<PropertyChangedMessage<Sfx>>(
                this, (action) => DispatcherHelper.CheckBeginInvokeOnUI(() => this.SfxDetail = action.NewValue));

With a simple google of "DispatcherHelper nullexception" I was led to this article by @aaronontheweb http://www.aaronstannard.com/post/2010/09/26/MVVM-Light-Toolkit-Pitfalls-on-Windows-Phone-7-and-How-to-Avoid-Them.aspx Why I didn't google that earlier is beyond me.... ;-)

I added "DispatcherHelper.Initialize();" to app.xaml.cs which fixed the problem. 

I believe the above mentioned article would be a great addition to the resources pages here at CodePlex and/or at http://galasoft.ch/mvvm/ perhaps in a section like "WP7 errata" or "WP7 notes" It details this fix and several others that wp7 mvvm light users may encounter. 

Would it be appropriate to include the "DispatcherHelper.Initialize();" in the wp7 project templates such that this is added to app.xaml.cs template?

Thank you, jeffa aka @jhalbrecht

Coordinator
Feb 27, 2012 at 6:40 PM
Hi,

There is no doubt that the documentation needs improving. I have big ambitions, but need to find the time for it. Releasing V4 takes absolute priority right now. Thanks for your suggestions, I can definitely do that in the meantime. Very sorry you had to bang your head ;-) don't hesitate to write to me directly (email, Twitter or here) if you have more worries.

Cheers
Laurent

Sent from my Windows Phone

From: jhalbrecht
Sent: 27.02.2012 09:48
To: laurent@galasoft.ch
Subject: wp7 DispatcherHelper.Initialize(); template inclusion? [mvvmlight:346445]

From: jhalbrecht

Thank you for MVVM light tool kit and the awesome documentation.

Recently I banged my head severely for hours on a Null exception from this:

            Messenger.Default.Register<PropertyChangedMessage<Sfx>>(
                this, (action) => DispatcherHelper.CheckBeginInvokeOnUI(() => this.SfxDetail = action.NewValue));

With a simple google of "DispatcherHelper nullexception" I was led to this article by @aaronontheweb http://www.aaronstannard.com/post/2010/09/26/MVVM-Light-Toolkit-Pitfalls-on-Windows-Phone-7-and-How-to-Avoid-Them.aspx Why I didn't google that earlier is beyond me.... ;-)

I added "DispatcherHelper.Initialize();" to app.xaml.cs which fixed the problem.

I believe the above mentioned article would be a great addition to the resources pages here at CodePlex and/or at http://galasoft.ch/mvvm/ perhaps in a section like "WP7 errata" or "WP7 notes" It details this fix and several others that wp7 mvvm light users may encounter.

Would it be appropriate to include the "DispatcherHelper.Initialize();" in the wp7 project templates such that this is added to app.xaml.cs template?

Thank you, jeffa aka @jhalbrecht

Feb 28, 2012 at 6:03 AM
lbugnion wrote:
Hi,

There is no doubt that the documentation needs improving. I have big ambitions, but need to find the time for it. Releasing V4 takes absolute priority right now. Thanks for your suggestions, I can definitely do that in the meantime. Very sorry you had to bang your head ;-) don't hesitate to write to me directly (email, Twitter or here) if you have more worries.

The upside to banging your head is it that it feels so good when you stop!