[Silverlight入门系列]App.xaml用途是什么?怎么传递参数和使用?
时间:2011-02-23 来源:Mainz
使用它里面的public参数很简单,假设在MainPage.xaml.cs你可以这样访问:
(Application.Current as App).YourPublicParam
同样,在Silverlight Class Library类库项目中你也可以用上面的方法访问App里面的变量,因为Application.Current是application全局的。
App.xaml来源
App.xaml和App.xaml.cs存在于Silverlight和WPF项目中,它来源于System.Windows.Application类库,如果熟悉Winform开发的就应该对这个东西比较熟悉。当Silverlight Application启动的时候,顺序是这样的:
- 把 Application_Startup 事件handler绑定到App.Startup属性
- 把Application_Exit 事件handler绑定到App.Exit 属性
- 把Application_UnhandledException事件handler绑定到UnhandledException 属性
- 触发InitializeComponent
- 创建新的 Page 对象实例
- 把 App.RootVisual 指向这个Page对象
- 调用Application.LoadComponent, 传递Uri 对象到 App.xaml
App.xaml用途

<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />
飞行射击 下载
<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />
飞行射击 下载
<img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />
飞行射击 下载- 4 <img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />下载73.78MB · 95℃
1970-01-01
- 5 <img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />下载43.7 MB · 95℃
1970-01-01
- 6 <img preview="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" width="32" height="32" src="http://pic.pdowncc.com/uploadimg/ico/2025/0523/1747993424374100.png" alt="弓箭勇者最新版" />下载110.69MB · 97℃
1970-01-01