This project has moved. For the latest updates, please go here.

Controlling which thread creates UI elements

Feb 15, 2011 at 8:31 AM
Edited Feb 15, 2011 at 8:40 AM

I'm using MEF with Unity in a WPF Prism context.

I'm running into problems with my ViewModels when they have visual elements. Is there a way to control on which thread the visual elements get instantiated? The problem is that the ViewModel gets created on a secondary thread and I have a Property for the View that is resolved via MEF - and this (understandibly) happens on the secondary thread making the runtime throw up.

Is there a work-around or is it just bad practise to instantiate visual elements via MEF?

EDIT: Turns out I'm an idiot. This had nothing to do with MEF, but rather me circumventing MEF... Just forget everything since "Good morning..."