1、新建项目
选择“新建”-“项目”,打开新建项目对话框
Visual C#语言下选择-Silverlight For Windows Phone-Windows Phone 应用程序
选择目标平台
生成项目
2、布局
生成的项目界面上会有两个TextBlock控件,这个控件大致相当于WinForm中的Lable控件,这个控件的Text属性可以修改显示出来的文本。
3、添加按钮
过程类似于WinForm中的拖控件,但是想修改Button显示的文本,却不是Text而是一个叫Content的属性,为什么是这样,因为这是SilverLight的规定,我也不知道为什么!
对了,控件名称在右上角,这个和WinForm有点区别
4、双击这个Button控件,添加事件代码:
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;
using Microsoft.Phone.Controls;
namespace Hello_World
{
public partial class MainPage : PhoneApplicationPage
{
// 构造函数
public MainPage()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
//添加事件代码
this.PageTitle.Text = "Hello World!"; //项目生成的其中一个TextBlock控件
}
}
}
5、效果
是不是很简单!!!