Web Development/Silverlight
[Silverlight] Silverlight 시작 시 실행 순서
thankee
2009. 10. 11. 18:35
Silverlight 시작 시 실행되는 순서입니다. Silverlight 문서 구조가 아래와 같다고 가정해봅시다.
APP
App.xaml
UserControls or resources
UserControls or resources
App.xaml.cs
App() //Constructor { InitializeComponent(); } Startup() //Startup Event { this.RootVisual = new MainPage(); }
MainPage
MainPage.xaml
UserControls or resources
UserControls or resources
MainPage.xaml.cs
MainPage() //Constructor { InitializeComponent(); } Loaded() //Startup Event { //Do something.. }
실행 흐름은 다음과 같습니다.
- App.xaml.cs의 App 생성자 실행
- InitializeComponent()의 실행
- App.xaml 해석 시작(이 곳에 포함된 모든 UserControl, Class, Resource들은 모두 초기화 또는 Instance화 됩니다.(즉 메모리에 모두 로드 됩니다.)
- RootVisual로 지정된 MainPage의 생성자 실행
- InitializeComponent()의 실행
- MainPage.xaml 실행(마찬가지로 이 곳에 포함된 모든 개체들이 초기화 되며 메모리에 로드 됩니다.)
- App의 Startup 이벤트 실행
- MainPage의 Loaded 이벤트 실행
- 끝. 위의 과정이 처음에 Application의 시작 시 실행되는 기본 흐름이며, 이 후부터는 기타 코드 실행, 이벤트 대기 및 처리 또는 프로그램 종료 등이 있겠죠.
몇 가지 주목할 만한 점은 다음과 같습니다.
- 반드시 App 개체부터 시작합니다.
- InitializeComponent에 의해서 Class의 xaml 페이지가 읽힙니다.
Author : thankee