Silverlight MVVM BFX Main Page Designer (Cider) CrossThreadAccess Error

Silverlight MVVM BFX Main Page Designer (Cider) CrossThreadAccess Error

Old forum URL: forums.lhotka.net/forums/t/10294.aspx


thaehn posted on Thursday, April 21, 2011

I have an app that is modeled after the one in the Silverlight MVVM video (SIDEMO).  The difference is I have an initial user control loaded into the MainContent region.  When I load the page in the Designer (Cider) I receive an exception: "InvalidCrossThreadAccess". I believe it is trying to create an instance of my viewmodel to display in the desinger.  Is there a way to tell the desinger not to render the contents or could I move my call to load the MainContent to another location?

RockfordLhotka replied on Thursday, April 21, 2011

Normally you'd include code in the viewmodel to not load the model when in design mode using code like:

if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))

If your viewmodel is a subclass of the Csla.Xaml ViewModelBase<T> class this will work because that is a subclass of DependencyObject. Otherwise you'll have to get a DO reference for this to work.

thaehn replied on Thursday, April 21, 2011

That worked!  Thanks! (I wish all problems were that easy to solve....)

Copyright (c) Marimer LLC