前几天由于自己的家里的电脑出了一点上的问题,重新做了一下系统,把所有的东西都重新做了一次,没有天急写这方面的文章。今天从公司里面把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%
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。