Welcome

首页 / 软件开发 / .NET编程技术 / Composite Application Guidance for WPF(3)

Composite Application Guidance for WPF(3)2012-02-07 博客园 周银辉创建第一个Composite WPF Application

1.前提条件:

你需要下载到CAL(Composite application library)库,实际上就是几个DLL文件,在项目中将会引用到他们来打造我们的程序,你可以从这里下载到它们。当然你也需要一个能打造WPF应用的IDE,比如VS2008。

2.创建Shell Project

2.1.在VS中新建一个WPF Application,将CAL库文件添加到项目引用中

2.2.将自动生成的Window1主窗口及其相应的文件重命名为Shell,其将作为我们的Composite App的Shell。

2.3.创建Bootstrapper,自定义程序初始化方式

新建一个Bootstrapper类,让其继承于Unity Bootstrapper,并重写其中的某些方法来实现我们的定制

  internal class Bootstrapper : UnityBootstrapper  {    protected override DependencyObject CreateShell()    {      var shell = new Shell();      shell.Show();      return shell;    }    protected override IModuleEnumerator GetModuleEnumerator()    {            return new StaticModuleEnumerator();    }}
我们通过重写CreateShell()方法指定我们的Shell,通过重写GetModuleEnumerator()方法来指定我们的模块加载方式(这里为了编译通过,我们暂时返回一个StaticModuleEnumerator,待会会介绍如何使用配置文件来配置模块的加载)