0
我使用Prism和Silverlight並將我的代碼基於MefBootstrapper。該定義如下:在引導程序中使用模塊中的服務CreateShell
public class MyBootstrapper : MefBootstrapper
{
protected override DependencyObject CreateShell()
{
return this.Container.GetExportedValue<MainPage>();
}
protected override void InitializeShell()
{
base.InitializeShell();
App.Current.RootVisual = (UIElement)this.Shell;
}
protected override Microsoft.Practices.Prism.Modularity.IModuleCatalog CreateModuleCatalog()
{
return Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml(new Uri("/My;component/ModulesCatalog.xaml", UriKind.Relative));
}
protected override void ConfigureAggregateCatalog()
{
base.ConfigureAggregateCatalog();
// Add this assembly
this.AggregateCatalog.Catalogs.Add(new DeploymentCatalog());
}
}
的具有的MainPage在其ImportingConstructor
生活在一個獨立的XAP,在ModulesCatalog.xaml設置爲InitializationMode="WhenAvailable"
,因爲我需要它的時候了一個組件。
我檢查了斷點,並且在CreateShell()
方法之前調用了CreateModuleCatalog()
方法,所以您會認爲我可以使用導入的模塊。但是,我注意到我的模塊的Initialize()
之前沒有調用CreateShell()
爲什麼不呢?我能做些什麼來完成這項工作?
那麼在構建我的shell之前,我該如何去等待那個呢? CreateShell方法是一種同步方法,它期望立即返回值... – Alex 2012-03-03 05:46:03