C# WPF 基础教程 视频学习笔记(五)

1.Application类
关闭模式 ShoutDownMode属性值如下
OnExpliciShutDown只有调用ShutDown时才会关闭
 
事件
 StartUp 调用Run方法后主窗口显示前调用
 Exit 应用程序关闭在Run即将返回前发生
 Activated当应用程序一个窗口**时发生
 DispatcherUnhandledException当应用程序发生异常时发生
 

2.Application类的任务
命令行参数设置:解决方案属性-》调试-》命令行参数

处理命令行参数在Startup事件中处理
private void Application_Startup(object sender, StartupEventArgs e)

3.该问当前Application对像
取得所有打开窗口对像 Application.Current.Windows

4.在窗口之间进行交互
App对像任何窗口都能取得对其的引用,取得APP对像代码如下
(App)Application.Current

5.单实例应用程序
单实例应用程序包装器创建

C# WPF 基础教程 视频学习笔记(五)