Silverlight开发:XAML与用户界面创建
1. Silverlight应用启动与事件处理
1.1 应用启动设置
在Silverlight应用中, Application
类的 RootVisual
属性决定了应用启动时显示的内容。以下是相关代码示例:
private void Application_Startup(object sender, StartupEventArgs e)
{
// Load the main control
this.RootVisual = new MainPage();
}
private void Application_Exit(object sender, EventArgs e)
{
}
private void Application_UnhandledException(object sender,
ApplicationUnhandledExceptionEventArgs e)
{
}
在上述代码中, Application_Startup
方法指定了应用启动时加载的主控件为 MainPage
。同时, App.xaml.cs
文件会注册所有应用级别的事件,如 Exit
和 UnhandledException
事件,不过它们的处理方法目前