Visual Studio 2015 新增了許多功能,

以下為支援開發Win10 通用視窗App的語言

1. C# 與 XAML(Extensible Application Markup Language)

2. VB與 XAML

3. C++與 XAML

4. Javascript與HTML5

在所有語言中, Visual Studio 都可以結合Blend用於設計精美的使用者介面(UI),

依照自己熟悉的語言進行開發^_^

(1) 程式進入點(Entry points)

C#程式進入點會是在App.xmal.cs寫在OnLaunched事件  

(2) 呈現技術(Presentation technology): XAML

(3) 資源(Assets): 這個跟之前寫Android手機程式概念相同, 一些圖片(不同解析度)等資源會放在這裡

(4) 非同步程式設計(Asynchronous programming): async/await 關鍵字

(5) 建立通用視窗的元件(Creating Universal Windows components): 打造一些可以重複使用的元件,

稱為windows執行期元件(windows runtime components)

(6) 封裝及佈署(Packaging and deployment): 利用清單設計(manifest designer)功能,

封裝應用程式以便佈署

應用程式架構 Model View ViewModel(MVVM)

1. Model: 也就是Data Model定義所需的資料來源, 資料來自本地端或是web service

2. ViewModel(資料處理邏輯): 透過C#類別中的屬性和方法, 用來與View做資料綁定

3. View: 以XAML設計使用者介面(UI), 接收或顯示資料, 不包含程式邏輯, 僅與ViewModel作資料綁定(Data Binding)

-----------------------------------------------------------------------------------------------------------------

image

使用預設值

image

image

點選MainPage.xaml

支援的目標裝置可以是以作業系統Windows 10的任何裝置, 包含手機, 平板, 電腦

image

按下綠色三角形按鈕, 直接編譯並測試執行

image

佈署完成…

image

執行結果如下:

image

加入一個TextBlock和一個Button

image

滑鼠雙擊Button可以加入Button click事件

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
 
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
 
namespace proj1
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }
 
        private void button_Click(object sender, RoutedEventArgs e)
        {
            textBlock.Text = DateTime.Now.ToString();
        }
    }
}

當按下Button後, TextBlock會顯示目前時間

image

點選Package.appxmanifest

image

修改預設語系: zh-TW

https://msdn.microsoft.com/en-us/windows/uwp/publish/supported-languages

image

設定啟動畫面圖案

image

執行結果

image

image



參考資料

1. 使用xaml及C# Windows 10 通用視窗App開發之鑰

2. Windows 8 看完就上手-在傳統桌面下開啟Windows 8 UI App

arrow
arrow
    全站熱搜

    me1237guy 發表在 痞客邦 留言(0) 人氣()