Silverlight学习笔记(二):创建Hello World 简单基础应用

使用Silverlight创建Hello World运用

1.创建HelloWorld项目

2.删除默认MainPage.xaml文件,添加Helloworld.xaml文件,同时修改App.xmal.cs中默认启用的xaml文件。

3.在Helloworld.xmal文件中配置页面显示:Helloworld页面添加按钮,点击按钮修改按钮显示名称

  <Grid x:Name="LayoutRoot" Background="Green">
        <Button Content="Button" Height="40"  Width="100" HorizontalAlignment="Left" Background="Red"
                Margin="120,118,0,0" Name="button1" VerticalAlignment="Top"
                Click="button1_Click_1" >

        </Button>
    </Grid>
   private void button1_Click_1(object sender, RoutedEventArgs e)
        {
            this.button1.Content = "您好!";
            this.LayoutRoot.Background = new SolidColorBrush(Colors.Red);
            this.button1.Background = new SolidColorBrush(Colors.Green);
        }

4.运行Helloworld项目,验证效果

 点击前:

点击后:

 

 

 

posted on 2014-04-08 16:06  不死小强  阅读(230)  评论(0编辑  收藏  举报

导航