SlideShare a Scribd company logo
Windows 8 Apps Dev.
整理及分享
Liyao Chen.
開發環境
OS: Windows 8
IDE: Visual Studio 2012
主要語言
C# + XAML
當然你也可以用
JavaScript + HTML + CSS
C++
不過這裡不討論就是了
主要語言     C# + XAML
C#有什麼厲害的地方?
  ● LINQ
  ● Lambda
  ● 非同步程式 Async / Await
XAML是什麼? 我只知道XML
  ● Data Binding
  ● INotifyPropertyChanged
  ● Bindable
C# - LINQ
以簡單、直覺的方式查詢資料,並且讓你為資料進行分組。-深
入淺出C#
C# - Lambda 物件搜尋?




參考資料:Huan-Lin學習筆記
C# - Lambda 物件資料子集?
C# - 非同步程式 Async / Await
避免效能瓶頸和增強應用程式整體回應。
讓畫面不會卡住,提升使用者經驗。




資料來源:msdn - async
C# - 非同步程式 Async / Await
過去我們這麼寫..




假設這個request花1秒完成,你就App就卡住1秒

資料來源:msdn - async
C# - 非同步程式 Async / Await
現在我們可以這樣寫..




呼叫此方法時會產生另一個"執行序"來執行任務,簡單來說就
是叫別人去買晚餐當你繼續看電視。
資料來源:msdn - async
XAML
XAML
XAML 的全名為 Extensible Application Markup Language,原為 WPF
(Windows Presentation Framework) 的一部份,是一種基於 XML 衍生而出的宣
告式使用者介面描述語言,外觀與 HTML 相似,平台會自動透過 .Net Framework
中的反射 (Reflection) 機制,將 XAML 中描述的物件,轉換為平台上使用的語言
宣告、定義,以方便在之後供 Code-Behind 的程式碼使用或是進行互動。
XAML+Data Binding
把物件屬性及內容綁給UI呈現




資料來源:msdn - data binding to controls
XAML+Data Binding

   setter / getter 必須




           將物件設定到 textBox1
XAML+Data Binding
Binding再進化 - INotifyProptertyChanged
物件資料更改時UI物件要能跟著更新
               繼承INotifyPropertyChenged
Binding再進化 - 有沒有更簡單的方式?
INotifyPropertyChanged = > Bindable

                                 繼承INotifyPropertyChenged




                                   實作SetProperty簡化Setter




有點複雜看不太懂...
Binding再進化 - 有沒有更簡單的方式?
INotifyPropertyChanged = > Bindable

沒關係,會用就好




                  原本的setter用不到囉




                            這樣簡單多了
MVVM
Model - View - ViewModel
Framework (MVVM)
Model:
用來描述資料實體(Entity)的簡單類別(Class),也可以在這邊實作商業邏輯以及與資
料庫溝通等資料存取相關的功能。
ViewModel:
供View使用的Model,透過公開的屬性(public property)給View進行Binding,供其
使用。
View:
其實就是XAML檔,也就是使用者介面
,使用者介面設計人員只需要在Blend中進行
對它的編輯,並透過Binding來和ViewModel
溝通(將DataContext指定為某個ViewModel,
以更進一步的與其中的屬性進行Binding)。



資料來源:[MVVM]初步認識MVVM設計模式
MVC vs MVVM
MVC
適合於大型系統,它可以分層且可以在實體層面切割為不同
的機器或服務,只要彼此間具有適當的通訊協定即可。


MVVM
適合像 XAML 這種與程式碼無關 (code ignorance) 的使用者
介面設計,只要 View 中下特定的指令與 ViewModel 串接,
就可以享有 ViewModel 溝通的功能,而 ViewModel 只需做
一些特別的介面實作,即可平順的和 View 溝通。

資料來源:[Architecture] MVP, MVC, MVVM, 傻傻分不清楚~
減少View的Code
                          MVVM              XAML code lines

Windows 8                   X                    751

WP8                         O                    121




資料來源:msdn - Implementing the MVVM Pattern
Windows 8
      and
Windows Phone 8
你可能以為他們都一樣
事情不是像憨人想的那麼簡單
Overlap of XAML controls
Windows 8              Windows Phone 8

AppBar                 ApplicationBar

ComboBox               ListPicker

GridView, ListView     LongListSelector,
                       LongListMultiSelector

ToggleSwitch           Toggle

VarableSizeWrapGrid,   WrapPanel
WrapGrid

WebView                WebBrowser

                       Panorama

                       Pivot


資料來源:msdn - XAML controls comparison
API Namespace
Windows 8
  Windows.UI.Xaml.Imaging

Windows Phone 8
  System.Windows.Media.Imaging
Navigation
Windows 8
  //直接傳物件
  Frame.Navigate(typeof(DetialsPage), e.CleckedItem);

Windows Phone 8
  //傳參數
  NavigationService.Navigate(
     new Uri("/DetailsPage.xaml?Id=10, UriKind.
     Relative));
還有很多
● Storing Files - Local
● Storing Files - Roaming
● ...
請參考WP to W8: API Mapping



還有許多  驚喜等你去發現。
Better way?
生命自然會找到它的出口...
Portable Libraries
Portable Libraries
Portable Libraries




資料來源:How to Make Portable Class Libraries Work for You
Portable 帶來的好處
Good
  Maintain同一份商業邏輯
  Unit Test
No Good
  Portable 所支援的API較少
Thanks
gliyao@gmail.com

More Related Content

PPTX
前端基础知识回顾
PPT
Ria lqj
PPTX
Asp.Net MVC 一教就上手
PDF
Jswebapps
PPTX
Knockout js
PPTX
Silverlight 开发简介
PPTX
20131004 - Backbone js 介紹 by Bryan
PDF
犀牛书第六版
前端基础知识回顾
Ria lqj
Asp.Net MVC 一教就上手
Jswebapps
Knockout js
Silverlight 开发简介
20131004 - Backbone js 介紹 by Bryan
犀牛书第六版

What's hot (6)

PPTX
Peggy 重新認識java script
PDF
ASP.NET MVC之實戰架構探討 -twMVC#5
PDF
AngularJS 開發 ASP.NET MVC -twMVC#9
PPTX
Html5及新特性
PPTX
ASP.NET MVC (Gi Days)
PDF
Html5form
Peggy 重新認識java script
ASP.NET MVC之實戰架構探討 -twMVC#5
AngularJS 開發 ASP.NET MVC -twMVC#9
Html5及新特性
ASP.NET MVC (Gi Days)
Html5form
Ad

Viewers also liked (20)

PPT
2011 05-28 pam marshall
PDF
Overzicht van The Collaborative Sale
PPS
Trabajo nuevo 3
PPT
De fyra elementen
PDF
Blogging - the why the how and the method for businesses and individuals
PPTX
Partner update 17 October 2014
PPTX
El planeta terra
PPS
Nuevo trabajo 5
PDF
Publicidade 2016
PDF
Dr. Jack West Oncology 2.0, to WA AG's Office
PDF
2011-12 hsaa - may 26-11
PPTX
Monitoring Rynku Hotelarskiego
PPTX
ClassDojo guía para estudiantes
PPT
Plegable molecular 2
DOCX
Scope & sequence 2011
PPTX
scc-apr-21-2011
PPTX
plegable molecular
PPTX
Sustainability issues in fashion
PDF
2 seqüències didàctiques ins jaume i
PDF
Kirill chebunin
2011 05-28 pam marshall
Overzicht van The Collaborative Sale
Trabajo nuevo 3
De fyra elementen
Blogging - the why the how and the method for businesses and individuals
Partner update 17 October 2014
El planeta terra
Nuevo trabajo 5
Publicidade 2016
Dr. Jack West Oncology 2.0, to WA AG's Office
2011-12 hsaa - may 26-11
Monitoring Rynku Hotelarskiego
ClassDojo guía para estudiantes
Plegable molecular 2
Scope & sequence 2011
scc-apr-21-2011
plegable molecular
Sustainability issues in fashion
2 seqüències didàctiques ins jaume i
Kirill chebunin
Ad

Similar to Windows 8 apps dev.整理及分享 (20)

PPT
Android应用开发 - 沈大海
PDF
Ajax设计技术
PPTX
Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天
PPT
Silverlight 2.0 完全新手學堂,基礎入門 10 大招
PDF
Learning JavaScript in Three Web Apps(中文)
PPT
Ecomm App Dev Chn
PDF
MobileWebAppFramework_V5_design
PPT
Bluemix Node-Red Part II
PPT
JdonFramework中文
PPT
Hibernate
PDF
Asp.net mvc網站的從無到有
PPTX
赶集团购开发总结4
PPT
Android -汇博
PPT
信息系统开发平台OpenExpressApp
PPT
Borland C++Builder 進階課程
DOC
J S教材
PDF
Cloud client : 达尔文信息云浏览器
PPTX
【项目分享】赶集移动Web App开发总结
PPT
教學投影片01_Vb2005
Android应用开发 - 沈大海
Ajax设计技术
Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天
Silverlight 2.0 完全新手學堂,基礎入門 10 大招
Learning JavaScript in Three Web Apps(中文)
Ecomm App Dev Chn
MobileWebAppFramework_V5_design
Bluemix Node-Red Part II
JdonFramework中文
Hibernate
Asp.net mvc網站的從無到有
赶集团购开发总结4
Android -汇博
信息系统开发平台OpenExpressApp
Borland C++Builder 進階課程
J S教材
Cloud client : 达尔文信息云浏览器
【项目分享】赶集移动Web App开发总结
教學投影片01_Vb2005

More from Liyao Chen (20)

PDF
KKBOX WWDC17 Xcode IDE - Hardy
PDF
KKBOX WWDC17 Xcode debug - Oliver
PDF
KKBOX WWDC17 WatchOS - Dada
PDF
KKBOX WWDC17 UIKit Drag and Drop - Mario
PDF
KKBOX WWDC17 UIKit - QQ
PDF
KKBOX WWDC17 Swift and Foundation - Liyao
PDF
KKBOX WWDC17 SiriKit and CoreSpotlight - Seraph
PDF
KKBOX WWDC17 Security - Antony
PDF
KKBOX WWDC17 Performance and Testing - Hokila
PDF
KKBOX WWDC17 Notification and Autolayout - Jefferey
PDF
KKBOX WWDC17 Airplay 2 - Dolphin
PDF
KKBOX WWDC17 Core Image - Daniel Tien
PDF
Auto Layout part 1
PDF
iOS Unit testing II
PDF
iOS Unit test getting stared
PDF
Continuous Integration
PDF
iOS Design to Code - Code
PDF
iOS Design to Code - Design
PDF
Beta testing with CI
PPTX
PTTHOT x IDEAS_HACKATHON 2014
KKBOX WWDC17 Xcode IDE - Hardy
KKBOX WWDC17 Xcode debug - Oliver
KKBOX WWDC17 WatchOS - Dada
KKBOX WWDC17 UIKit Drag and Drop - Mario
KKBOX WWDC17 UIKit - QQ
KKBOX WWDC17 Swift and Foundation - Liyao
KKBOX WWDC17 SiriKit and CoreSpotlight - Seraph
KKBOX WWDC17 Security - Antony
KKBOX WWDC17 Performance and Testing - Hokila
KKBOX WWDC17 Notification and Autolayout - Jefferey
KKBOX WWDC17 Airplay 2 - Dolphin
KKBOX WWDC17 Core Image - Daniel Tien
Auto Layout part 1
iOS Unit testing II
iOS Unit test getting stared
Continuous Integration
iOS Design to Code - Code
iOS Design to Code - Design
Beta testing with CI
PTTHOT x IDEAS_HACKATHON 2014

Windows 8 apps dev.整理及分享