Silverlight

03.SilverLight3 - Application 클래스

Godffs 2009. 11. 24. 08:59
반응형
Application 클래스
- 실버라이트의 시작과 종료를 관리
- Startup 이벤트
   : 실버라이트 응용 프로그램이 시작할 때 발생
- RootVisual 속성
  : 실버라이트 응용 프로그램의 EntryPoint
  : C#의 Main 메서드와 비슷한 역할

시작페이지를 변경하는 예제입니다.
먼저 페이지를 두개 사용하기 위해 메인페이지 외에 Silverlight User Control를 추가합니다. (Subpage.xaml)

Grid 태그 안에 작성

MainPage.xaml

<Grid x:Name="LayoutRoot" Background="White">

    <TextBlock x:Name="lblTitle" Text="Application Class" FontSize="30"></TextBlock>

</Grid>


Subpage.xaml

<Grid x:Name="LayoutRoot" Background="White">

    <TextBlock x:Name="lblTitle" Text="Sub Page!!" FontSize="30" FontFamily="Verdana">  

    </TextBlock>

</Grid>

결과화면

[그림3-1]


시작페이지 MainPage.xaml을 SubPage.xaml로 변경하는 예제입니다.
솔루션탐색기에서 App.xaml의 코드비하인드 페이지로 이동합니다. App.xaml.cs
App.xaml.cs

private void Application_Startup(object sender, StartupEventArgs e)

{

        //

        //this.RootVisual = new MainPage(); //

        this.RootVisual = new SubPage(); //

}


F5를 눌러 디버깅을 실행해주시면 결과를 확인 할 수 있습니다.


반응형