silverlight 2.0 入门教程(一)

 

前几天由于自己的家里的电脑出了一点上的问题,重新做了一下系统,把所有的东西都重新做了一次,没有天急写这方面的文章。今天从公司里面把silverlight 2.0 的SDK下载了下来,这里我就不说这么多的话吧,还是来看看哟
首先在这里声明一点,可能没有其他的高手写得哪么的精,但是我的文章是为了给初学者一点帮助就OK了

在你自己的电脑按装VS2008,装好以后可到关方网站上下一个silverlight 2.0 SDK,这个SDK大约有50M,也不很大,
注:如果你是VS2005,你是安装不上的2.0的SDK,只有VS2008才可以,这个我自己测试过;安装这个有一点慢,要用心等,

上面的工作完了以后,我们就可以开始建一个项目了
这里可以在你的项目中会出一silverlight 这个模板,选择它,会出一个对话框子,这里可以任一选一个,都可以,主要是用来托管它,在我们的解决方案中就会出现,
这是我们不做任何的操作,只将我们的项目重新生成一下就OK了,会发现我们的工程中有多了一个文件夹,这个文件夹把所有的silverlight 用来的DLL通过了高压缩。

后下面的代码:
代码说明:
HorizontalAlihnment:是Grid排版方面,他有四个值,Stretch,right,center,left
showGridLines:显示出Grid中的网格线,默认为false
在给按钮加事件时,只要我们给按钮取上一个名字,在page.xaml.cs后台代码会自动给我们写来,
我们只是写事件下面应该做什么就OK

< UserControl x:Class = " SilverlightApplication1.Page "
    xmlns
= " http://schemas.microsoft.com/client/2007 "  
    xmlns:x
= " http://schemas.microsoft.com/winfx/2006/xaml "  
    Width
= " 400 "  Height = " 300 " >
    
< Grid x:Name = " LayoutRoot "  Background = " Blue "  HorizontalAlignment = " Left "  ShowGridLines = " True " >
        
< Grid.RowDefinitions >
            
< RowDefinition Height = " 100 " />
            
< RowDefinition Height = " 100 " />
            
< RowDefinition Height = " 100 " />
        
</ Grid.RowDefinitions >
        
< Grid.ColumnDefinitions >
            
< ColumnDefinition Width = " 100 " />
            
< ColumnDefinition Width = " 100 " />
            
< ColumnDefinition Width = " 100 " />
        
</ Grid.ColumnDefinitions >
        
< Button x:Name = " MyButton "  Content = " Push Me "  Width = " 100 "  Height = " 50 "  Grid.Column = " 1 "  Grid.Row = " 0 "  Click = " MyButton_Click " ></ Button >
        
< Button x:Name = " MyButton2 "  Content = " Button2 "  Width = " 100 "  Height = " 50 "  Grid.Column = " 0 "  Grid.Row = " 1 "  Click = " MyButton2_Click " ></ Button >
        
< Button x:Name = " MyButton3 "  Content = " Button3 "  Width = " 100 "  Height = " 50 "  Grid.Column = " 2 "  Grid.Row = " 1 "  Click = " MyButton3_Click " ></ Button >
        
< Button x:Name = " MyButton4 "  Content = " Button4 "  Width = " 100 "  Height = " 50 "  Grid.Column = " 1 "  Grid.Row = " 2 "  Click = " MyButton4_Click " ></ Button >
        
< Button x:Name = " MyButton5 "  Content = " Button5 "  Width = " 100 "  Height = " 50 "  Grid.Column = " 2 "  Grid.Row = " 0 "  Click = " MyButton5_Click " ></ Button >
        
    
</ Grid >
</ UserControl >

 

Page.xaml.cs 代码:

using  System;
using  System.Collections.Generic;
using  System.Linq;
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  SilverlightApplication1
{
    
public partial class Page : UserControl
%
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值