Silver Light

SilverLight 시작하기 - Hello

원찬식 2009. 2. 11. 14:06

모든 프로그램의 시작은 Hello라는 문자를 찍는데서 시작이 되고 DB와 연동되는 게시판으로 마무리가 되면 초급의 딱지는 띄는거라 생각 한다.

그래서 실버라이트도 초급을 띄기 위해 오늘은 Hello를 찍어 보았다.

우선 C#으로 해서 SilverLight 응용프로그램을 추가 해보았다.

1. .NET Framework를 3.5(Default)로 잡아 주고
2. Silverlight 응용 프로그램을 선택한 후  파일 이름을 주고 확인을 누르면
3. 응용프로그램 선택하는것이 나오는 그땐 그냥 다음을 누르자. 이게 서버에서 도는것인지 아님 로컬에서도 돌게 할것인지 결정하는거 같았다.

그러고 나면 XAML페이지와 SSPX 페이지 가 나왔다. 그리고 cs파일도 생성이 되었고 플랙스와 마찬가지로 js와 HTML페이지도 생성이 되었다.

여기까지만 보면 플렉스와 비슷한듯 싶다.
xaml이 MXML인듯 싶고 cs 가 as 인듯 싶다.

그러고 나선 코딩이 들어 간다. ㅋㅋ

Page.xaml 의 내용은

<UserControl x:Class="Hello.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <StackPanel Orientation="Vertical">
            <TextBox x:Name="txtBox"/>
            <Button Content="Click"  FontSize="12" Click="Button_Click" Name="sadff"/>
         
        </StackPanel>
    </Grid>
</UserControl>


Page.xaml.cs의 파일 내용은
  using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Hello
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            txtBox.Text += "Hello" + Environment.NewLine;
        }
    }
}



이렇게 구성이 된다.

그럼 컴파일을 해 보고 실행을 해 보면
이런 화면이 실행 된다.

음.. 아주 간단하다..

별거 없드라 ㅋㅋ

이젠 슬슬 컴포넌트에 대해서도 공부 해 봐야 알겠지만 아직까지는 플랙스와 뭔차인지 모르겠다.

실버라이트는 설치하는데 한나절 다 보내게 만들고 (심지어 윈도우까지 새로 깔았지만...) 아직까진 플렉스가 더 나은듯 싶다. ㅋㅋ (원래 모르면 어려운법 헤헤)