我觉得这篇文章比较详细的介绍了HelloWorld的这个Sample示例程序,参考地址(http://www.cnblogs.com/hegezhou_hot/archive/2012/12/21/2828162.html)
我在学习过程中的笔记如下:
1.程序入口
WPF程序的入口在vs自动给我们生成的App.xaml和App.xaml.cs文件中体现,目前见到的有两种方式:
①App.xaml中设置启动项:
StartupUri="********.xaml"
②App.xaml.cs中设置启动项(通过override OnStartup函数):
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
//TODO your code
Bootstrapper bootstrapper = new Bootstrapper();
bootstrapper.Run();
}
这个方法在运行app.Run()的时候触发。
2.Bootstrapper
这是一个继承自UnityBootstrapper的类,代码如下:
class Bootstrapper : UnityBootstrapper
{
protected override DependencyObject CreateShell()
{
return this.Container.Resolve<Shell>();
}
protected override void InitializeShell()
{
base.InitializeShell();