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