WP程序开发——Hello World

1、新建项目

CG~W@0(8{DRL(HDHE(RIF1Z

选择“新建”-“项目”,打开新建项目对话框

Visual C#语言下选择-Silverlight For Windows Phone-Windows Phone 应用程序

UJLC8C9AB0VRX(4Q@1`4UTW

选择目标平台

生成项目

2、布局

image

生成的项目界面上会有两个TextBlock控件,这个控件大致相当于WinForm中的Lable控件,这个控件的Text属性可以修改显示出来的文本。

3、添加按钮

image

过程类似于WinForm中的拖控件,但是想修改Button显示的文本,却不是Text而是一个叫Content的属性,为什么是这样,因为这是SilverLight的规定,我也不知道为什么!

对了,控件名称在右上角,这个和WinForm有点区别

image

4、双击这个Button控件,添加事件代码:

)UHBBS$Y6GFJXHR6OEZDC)1

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、效果

4UY_9[4J2LM[ZWGHA4S14{7

AR[2C@18$D~BA~7R0`5Q$ZP

是不是很简单!!!

原文地址:https://www.cnblogs.com/wangluojisuan/p/2815968.html