WP程式開發——Hello World

來源:互聯網
上載者:User

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

是不是很簡單!!!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.