SlideShare ist ein Scribd-Unternehmen logo
1 von 74
Downloaden Sie, um offline zu lesen
Nguyen Tuan | Microsoft Certified Trainer
• Windows Design
• Designing an Applications
• Working with XAML Layout
• Styles & Themes in WP8.
• Design Considerations
• Model-View-ViewModel
• Application Lifecycle
Agenda
8/16/2014 3
Windows Phone Design
Metro styles or Windows Phone Design Style?
• The Windows Phone team have taken a lot of
trouble over the look and feel of the phone
• They have created a design style, inspired by
metropolitan signage, to express this
• Programs on the phone should reflect this style
4
Take care of the details
Make it safe and reliable
Uncompromising Sensitivity to Weight, Balance and Scale
Align to the grid
Principle: Be fast and fluid
Life is mobile
Delight with motion
Design for touch
Intuitive interaction
Be responsive and ready
Immersive and compelling
Principles: Do more with less
Be great at something
Focused and direct
Content before chrome
Inspire confidence
Principle: Authentically Digital
Don’t Try to be What It’s NOT
Cloud connected
Dynamic and alive
Beautiful use of typography
Bold vibrant colours
Motion
Principle: Win as one
Fit into the UI model
Reduce redundancy
Work together to complete scenarios
Tools and templates are designed to scale
Principles
Pride in craftsmanship
Be Fast and Fluid
Win as One
Do More with Less
Authentically Digital
13
Paper prototyping
User Experience Bar Document
18
19
20
21
22
23
24
Introduction to XAML
Layout
8/16/2014
2
5
Pivot Pages
• <phone:PhoneApplicationPage
x:Class="ContosoCookbook.RecipeDetailPage"
... />
<Grid x:Name="LayoutRoot" Background="Transparent">
<phone:Pivot Title=“PIVOT APPLICATION">
<!--Pivot item one-->
<phone:PivotItem Header=“item1">
<Grid>
</Grid>
</phone:PivotItem>
<!--Pivot item two-->
<phone:PivotItem Header=“item2">
<Grid>
</Grid>
</phone:PivotItem>
</phone:Pivot>
</Grid>
</phone:PhoneApplicationPage>
27
Pivot
Control
Pivot
Headers
Pivot
Items
Control
29
30
XAML Element Class Hierarchy
• The XAML class hierarchy is
quite complex
• Everything is based on the
FrameworkElement class which
contains the fundamental properties
of all elements
• You can derive your own components
if you wish
31
FrameworkElement
TextBlock
TextBox ContentControl
ButtonBase
Button
Control
Elements and XAML
32
<!--Pivot item one-->
<phone:PivotItem Header="recipe">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="240"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image x:Name="RecipeImage" Stretch="UniformToFill"/>
<ScrollViewer Grid.Row="1">
<TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap" />
</ScrollViewer>
<StackPanel Grid.Row="2" Orientation="Horizontal">
<TextBlock Text="Prep time: " />
<TextBlock MinWidth="200" x:Name="PrepTimeTextBlock" />
</StackPanel>
</Grid>
</phone:PivotItem>
Grid Container Element
33
<!--Pivot item one-->
<phone:PivotItem Header="recipe">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="240"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image x:Name="RecipeImage" Stretch="UniformToFill"/>
<ScrollViewer Grid.Row="1">
<TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap" />
</ScrollViewer>
<StackPanel Grid.Row="2" Orientation="Horizontal" >
<TextBlock Text="Prep time: " />
<TextBlock MinWidth="200" x:Name="PrepTimeTextBlock" />
</StackPanel>
</Grid>
</phone:PivotItem>
8/16/2014 34
• Button at bottom of Designer window can be
used to show a 12px alignment Grid
• Useful for setting alignment of elements
• Available in Blend
• Now also available in Visual Studio
Visual Studio and Blend Alignment Grid
8/16/2014 35
• All new projects include AlignmentGrid.png in the Assets folder
• You can overlay the grid at design and runtime by uncommenting
the XAML that shows it
• Included near the foot of MainPage.xaml
• Copy to other pages to show on those
<!--Uncomment to see an alignment grid to help ensure your controls are
aligned on common boundaries. The image has a top margin of -32px to
account for the System Tray. Set this to 0 (or remove the margin altogether)
if the System Tray is hidden.
Before shipping remove this XAML and the image itself.-->
<!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0"
Grid.RowSpan="2" IsHitTestVisible="False" />-->
Alignment Grid Overlay
36
Using the Alignment Grid
8/16/2014 37
<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top"
Height="800" Width="480" Margin="0,-32,0,0"
Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />
<phone:PivotItem Header="recipe">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="240"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image x:Name="RecipeImage" Margin="12" Stretch="UniformToFill"/>
<ScrollViewer Grid.Row="1">
<TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap" Margin="12,0,0,0" />
</ScrollViewer>
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="12" HorizontalAlignment="Left" >
<TextBlock Text="Prep time: " Margin="0" />
<TextBlock x:Name="PrepTimeTextBlock" />
</StackPanel>
</Grid>
</phone:PivotItem>
Use Margin Property to Insert Spacing
38
Demo
GridsRowsAndColumns
Styles and Themes
8/16/2014
• You can set colors and font sizes for elements directly in XAML:
<ScrollViewer Grid.Row="1">
<TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap"
Margin="12,0,0,0" Foreground="White" FontSize="12" />
</ScrollViewer>
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="12" HorizontalAlignment="Left" >
<TextBlock Text="Prep time: " Margin="0" Foreground="White"/>
<TextBlock x:Name="PrepTimeTextBlock" Foreground="LightGray" FontSize="24" />
</StackPanel>
• This is generally a BAD IDEA!
• Difficult to match builtin styles
• Difficult to work with Windows Phone Themes
Applying Styles to Elements
8/16/2014 41
Foreground Colors and Themes
8/16/2014 42
<phone:PivotItem Header="recipe">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="240"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image x:Name="RecipeImage" Margin="12" Stretch="UniformToFill"/>
<ScrollViewer Grid.Row="1">
<TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap"
Margin="12,0,0,0" Style="{StaticResource PhoneTextSmallStyle}" />
</ScrollViewer>
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="12" HorizontalAlignment="Left" >
<TextBlock Text="Prep time: " Margin="0" Style="{StaticResource PhoneTextNormalStyle}" />
<TextBlock x:Name="PrepTimeTextBlock" Style="{StaticResource PhoneTextSubtleStyle}" />
</StackPanel>
</Grid>
</phone:PivotItem>
Use Built-In Styles
43
New in VS2012 – Apply Styles in Visual Studio
8/16/2014 44
Demo
AlignmentAndMargins
The MVVM pattern
From MVC
Model View
Controller
Presentation Model
(ViewModel)
To MVVM
Model View
The relationships
View
ViewModel
DataBinding Commands Services
Messages
Model
Commands
“Point of entry” for a method Can be data
bound
ICommand interface
Execute method
CanExecute method
CanExecuteChanged event
Implementing commands
It’s quite a lot of work
Most toolkits and frameworks have a “relay”
implementation
RelayCommand (MVVM Light)
DelegateCommand (PRISM)
…
Why MVVM?
Model
public class KittenObject
{
public KittenObject() { }
public string KittenImage { get; set; }
public string KittenName { get; set; }
public string KittenAge { get; set; }
}
Why MVVM?
ViewModel
public class MainViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (null != handler)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Why MVVM?
ViewModel
private string _sampleProperty = "my start value";
public string SampleProperty
{
get { return _sampleProperty; }
set
{
_sampleProperty = value;
NotifyPropertyChanged("SampleProperty");
}
}
Why MVVM?
View
<TextBlock Text="{Binding SampleProperty, Mode=TwoWay}" />
Why MVVM?
View
<phone:LongListSelector
ItemsSource="{Binding MyListOfItems}"
SelectedItem="{Binding MySelectedItem, Mode=TwoWay}" />
Model-View-ViewModel
View
ViewModel
Commands
Data
Binding
Model
Data Binding Modes
• The Mode property determines how changes
are synchronized between the target control and
data source
• OneTime – Control property is set once to the data value
and any subsequent changes are ignored
• OneWay – Changes in the data object are synchronized to
the control property, but changes in the control are not
synchronized back to the data object
• TwoWay – Changes in the data object are synchronized to
the control property and vice-versa
<TextBlock x:Name="ContentText"
Text="{Binding LineThree, Mode=OneWay}"/>
• In the XAML snippet, make sure
that the DataContext is set to an
instance of the ViewModel class.
• The ViewModel class exposes an
AddCommand property of type
AddItemCommand
• The ViewModel is responsible for
actually adding a new item
Commands
<Button Command="{Binding AddCommand}"
CommandParameter="Untitled" Content="Button"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
class AddItemCommand : ICommand
{
ViewModel _viewModel;
public AddItemCommand(ViewModel viewModel)
{
_viewModel = viewModel;
}
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{
return true;
}
public void Execute(object title)
{
_viewModel.AddItem(title as string);
}
}
MVVM Benefits
• Reuse Model and View-Model code
• Test the ViewModel with unit tests
• Maintainability
• Can show design-time data in Expression Blend
and the Visual Studio designer
Demo
SimpleDataBinding
MVVM Libraries
http://caliburnmicro.codeplex.com/http://mvvmlight.codeplex.com/
Rob EisenbergLaurent Bugnion
Not running
Running
Launching
Running
Not running
Running
LaunchingClosing
Deactivating
Dormant
Exit
Application_Closing
Deactivate
Application_Deactivated
Closing vs Deactivating
Dormant
Not running
Running
LaunchingClosing
DeactivatingActivating
Dormant
Dormant
Tombstoned
Not running
Running
LaunchingClosing
DeactivatingActivating
Dormant
Tombstoned
Tombstoned
Not running
Running
LaunchingClosing
DeactivatingActivating
Dormant
Tombstoned or Dormant?
private void Application_Activated(object sender,
ActivatedEventArgs e)
{
if (e.IsApplicationInstancePreserved)
{
// Dormant - objects in memory intact
}
else
{
// Tombstoned - need to reload
}
}
Fast Application Resume
Tombstoned
Not running
Running
LaunchingClosing
DeactivatingActivating
Dormant
Enabling FAR in PropertiesWMAppManifest.xml
<Tasks>
<DefaultTask Name ="_default" NavigationPage="MainPage.xaml">
<BackgroundExecution>
<ExecutionType Name="LocationTracking" />
</BackgroundExecution>
</DefaultTask>
</Tasks>
<Tasks>
<DefaultTask Name ="_default“ NavigationPage="MainPage.xaml“ />
</Tasks>
Why Not Use FAR All The Time?
Launch
from
Start
Page 1 Page 2
Launch
from
Start
Page 2deep link
Why Not Use FAR All The Time?
Launch
from
Start
Page 1 Page 2
Launch
from
Start
Page 2FARPage 1
Demo
1. AppLifeCycle
2. Lifetime
Review
• Windows Phone Design has five key principles:
• Clean, Light, Open, Fast
• Celebrate Typography
• Alive in Motion
• Content, Not Chrome
• Authentically Digital
• WP8 use XAML to express the design of their user interface
• The design is expressed in a XAML text file that defines and arranges display elements
• There are a set of project templates for applications based on the Windows
Phone design
• In Blend, you can create design-time data to aid during design of a UI
• Databinding in XAML allows you to declaratively markup UI elements to link
them to a property of a data class
• List controls define layout using XAML Templates

Weitere ähnliche Inhalte

Was ist angesagt?

Mvc & java script
Mvc & java scriptMvc & java script
Mvc & java scriptEyal Vardi
 
QCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UIQCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UIOliver Häger
 
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Ayes Chinmay
 
Java script frame window
Java script frame windowJava script frame window
Java script frame windowH K
 
MongoDB & NoSQL 101
 MongoDB & NoSQL 101 MongoDB & NoSQL 101
MongoDB & NoSQL 101Jollen Chen
 
Introduction to javascript templating using handlebars.js
Introduction to javascript templating using handlebars.jsIntroduction to javascript templating using handlebars.js
Introduction to javascript templating using handlebars.jsMindfire Solutions
 
XML Business Rules Validation with Schematron
XML Business Rules Validation with SchematronXML Business Rules Validation with Schematron
XML Business Rules Validation with SchematronEmiel Paasschens
 

Was ist angesagt? (8)

Mvc & java script
Mvc & java scriptMvc & java script
Mvc & java script
 
QCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UIQCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UI
 
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
 
Java script frame window
Java script frame windowJava script frame window
Java script frame window
 
MongoDB & NoSQL 101
 MongoDB & NoSQL 101 MongoDB & NoSQL 101
MongoDB & NoSQL 101
 
Bootstrap 4 ppt
Bootstrap 4 pptBootstrap 4 ppt
Bootstrap 4 ppt
 
Introduction to javascript templating using handlebars.js
Introduction to javascript templating using handlebars.jsIntroduction to javascript templating using handlebars.js
Introduction to javascript templating using handlebars.js
 
XML Business Rules Validation with Schematron
XML Business Rules Validation with SchematronXML Business Rules Validation with Schematron
XML Business Rules Validation with Schematron
 

Andere mochten auch

Intro to social media for the mastermind group 1 2011
Intro to social media for the mastermind group 1 2011Intro to social media for the mastermind group 1 2011
Intro to social media for the mastermind group 1 2011RipMedia Group,
 
Lauren’s lovely long lasting summer
Lauren’s lovely long lasting summerLauren’s lovely long lasting summer
Lauren’s lovely long lasting summerThe Lower School
 
Mongara Sammanfattning Mats Petersson
Mongara Sammanfattning Mats PeterssonMongara Sammanfattning Mats Petersson
Mongara Sammanfattning Mats PeterssonMongara AB
 
Lean, Svensk Bensinhandel, Mongara, Gran Canaria 2012
Lean, Svensk Bensinhandel, Mongara, Gran Canaria 2012Lean, Svensk Bensinhandel, Mongara, Gran Canaria 2012
Lean, Svensk Bensinhandel, Mongara, Gran Canaria 2012Mongara AB
 
Digital eng
Digital engDigital eng
Digital engbeerguy
 
McAfee Application Control
McAfee Application ControlMcAfee Application Control
McAfee Application ControlAndrei Novikau
 
Ca aquarium trip powerpoint final
Ca aquarium trip powerpoint finalCa aquarium trip powerpoint final
Ca aquarium trip powerpoint finalAnna Donskoy
 
Serap Mutlu Akbulut Korosu 2 Haziran 2015 Konseri
Serap Mutlu Akbulut Korosu 2 Haziran 2015 KonseriSerap Mutlu Akbulut Korosu 2 Haziran 2015 Konseri
Serap Mutlu Akbulut Korosu 2 Haziran 2015 Konseriaokutur
 
Digital eng
Digital engDigital eng
Digital engbeerguy
 
Инфраструктурные проекты_Российская технологическая инициатива
Инфраструктурные проекты_Российская технологическая  инициатива Инфраструктурные проекты_Российская технологическая  инициатива
Инфраструктурные проекты_Российская технологическая инициатива Ingria. Technopark St. Petersburg
 
Информатизация образования. Итоги работы за 2009/2010 учебный год
Информатизация образования. Итоги работы за 2009/2010 учебный годИнформатизация образования. Итоги работы за 2009/2010 учебный год
Информатизация образования. Итоги работы за 2009/2010 учебный годVladimir
 
Kartagen4new
Kartagen4newKartagen4new
Kartagen4newOpanki Gm
 
Staying Ahead of the Game - The Steps to Effective Crisis Communications Plan...
Staying Ahead of the Game - The Steps to Effective Crisis Communications Plan...Staying Ahead of the Game - The Steps to Effective Crisis Communications Plan...
Staying Ahead of the Game - The Steps to Effective Crisis Communications Plan...prnewswire
 
Юлия Артамонова - Проблемы реализации кластерной политики центрами кластерног...
Юлия Артамонова - Проблемы реализации кластерной политики центрами кластерног...Юлия Артамонова - Проблемы реализации кластерной политики центрами кластерног...
Юлия Артамонова - Проблемы реализации кластерной политики центрами кластерног...Ingria. Technopark St. Petersburg
 

Andere mochten auch (20)

Intro to social media for the mastermind group 1 2011
Intro to social media for the mastermind group 1 2011Intro to social media for the mastermind group 1 2011
Intro to social media for the mastermind group 1 2011
 
Lauren’s lovely long lasting summer
Lauren’s lovely long lasting summerLauren’s lovely long lasting summer
Lauren’s lovely long lasting summer
 
Mongara Sammanfattning Mats Petersson
Mongara Sammanfattning Mats PeterssonMongara Sammanfattning Mats Petersson
Mongara Sammanfattning Mats Petersson
 
Lean, Svensk Bensinhandel, Mongara, Gran Canaria 2012
Lean, Svensk Bensinhandel, Mongara, Gran Canaria 2012Lean, Svensk Bensinhandel, Mongara, Gran Canaria 2012
Lean, Svensk Bensinhandel, Mongara, Gran Canaria 2012
 
Ingria gamification
Ingria gamificationIngria gamification
Ingria gamification
 
Digital eng
Digital engDigital eng
Digital eng
 
McAfee Application Control
McAfee Application ControlMcAfee Application Control
McAfee Application Control
 
Ca aquarium trip powerpoint final
Ca aquarium trip powerpoint finalCa aquarium trip powerpoint final
Ca aquarium trip powerpoint final
 
Serap Mutlu Akbulut Korosu 2 Haziran 2015 Konseri
Serap Mutlu Akbulut Korosu 2 Haziran 2015 KonseriSerap Mutlu Akbulut Korosu 2 Haziran 2015 Konseri
Serap Mutlu Akbulut Korosu 2 Haziran 2015 Konseri
 
Tips2017.02.08
Tips2017.02.08Tips2017.02.08
Tips2017.02.08
 
Digital eng
Digital engDigital eng
Digital eng
 
Chuan
ChuanChuan
Chuan
 
Mining for gold 2.0
Mining for gold 2.0Mining for gold 2.0
Mining for gold 2.0
 
Инфраструктурные проекты_Российская технологическая инициатива
Инфраструктурные проекты_Российская технологическая  инициатива Инфраструктурные проекты_Российская технологическая  инициатива
Инфраструктурные проекты_Российская технологическая инициатива
 
Информатизация образования. Итоги работы за 2009/2010 учебный год
Информатизация образования. Итоги работы за 2009/2010 учебный годИнформатизация образования. Итоги работы за 2009/2010 учебный год
Информатизация образования. Итоги работы за 2009/2010 учебный год
 
Kartagen4new
Kartagen4newKartagen4new
Kartagen4new
 
Staying Ahead of the Game - The Steps to Effective Crisis Communications Plan...
Staying Ahead of the Game - The Steps to Effective Crisis Communications Plan...Staying Ahead of the Game - The Steps to Effective Crisis Communications Plan...
Staying Ahead of the Game - The Steps to Effective Crisis Communications Plan...
 
Camp Manitou
Camp ManitouCamp Manitou
Camp Manitou
 
Юлия Артамонова - Проблемы реализации кластерной политики центрами кластерног...
Юлия Артамонова - Проблемы реализации кластерной политики центрами кластерног...Юлия Артамонова - Проблемы реализации кластерной политики центрами кластерног...
Юлия Артамонова - Проблемы реализации кластерной политики центрами кластерног...
 
ShareCafé 2 - Werk slimmer door geïntegreerde tools
ShareCafé 2 - Werk slimmer door geïntegreerde toolsShareCafé 2 - Werk slimmer door geïntegreerde tools
ShareCafé 2 - Werk slimmer door geïntegreerde tools
 

Ähnlich wie 02.Designing Windows Phone Application

Asp.net mvc training
Asp.net mvc trainingAsp.net mvc training
Asp.net mvc trainingicubesystem
 
The Magic of WPF & MVVM
The Magic of WPF & MVVMThe Magic of WPF & MVVM
The Magic of WPF & MVVMAbhishek Sur
 
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its featuresAbhishek Sur
 
Building Modern Websites with ASP.NET by Rachel Appel
Building Modern Websites with ASP.NET by Rachel AppelBuilding Modern Websites with ASP.NET by Rachel Appel
Building Modern Websites with ASP.NET by Rachel Appel.NET Conf UY
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksHjörtur Hilmarsson
 
Android Lab Test : Using the WIFI (english)
Android Lab Test : Using the WIFI (english)Android Lab Test : Using the WIFI (english)
Android Lab Test : Using the WIFI (english)Bruno Delb
 
SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015Pushkar Chivate
 
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5Tieturi Oy
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Eric Palakovich Carr
 
Windows Phone 8 - 3 Building WP8 Applications
Windows Phone 8 - 3 Building WP8 ApplicationsWindows Phone 8 - 3 Building WP8 Applications
Windows Phone 8 - 3 Building WP8 ApplicationsOliver Scheer
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinBarry Gervin
 
Data binding 入門淺談
Data binding 入門淺談Data binding 入門淺談
Data binding 入門淺談awonwon
 
Effective Android Data Binding
Effective Android Data BindingEffective Android Data Binding
Effective Android Data BindingEric Maxwell
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2Paras Mendiratta
 

Ähnlich wie 02.Designing Windows Phone Application (20)

Xaml programming
Xaml programmingXaml programming
Xaml programming
 
Asp.net mvc training
Asp.net mvc trainingAsp.net mvc training
Asp.net mvc training
 
Asp.NET MVC
Asp.NET MVCAsp.NET MVC
Asp.NET MVC
 
The Magic of WPF & MVVM
The Magic of WPF & MVVMThe Magic of WPF & MVVM
The Magic of WPF & MVVM
 
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its features
 
Building Modern Websites with ASP.NET by Rachel Appel
Building Modern Websites with ASP.NET by Rachel AppelBuilding Modern Websites with ASP.NET by Rachel Appel
Building Modern Websites with ASP.NET by Rachel Appel
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & Tricks
 
Android Lab Test : Using the WIFI (english)
Android Lab Test : Using the WIFI (english)Android Lab Test : Using the WIFI (english)
Android Lab Test : Using the WIFI (english)
 
SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015
 
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
 
Mini-Training: AngularJS
Mini-Training: AngularJSMini-Training: AngularJS
Mini-Training: AngularJS
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
 
Windows Phone 8 - 3 Building WP8 Applications
Windows Phone 8 - 3 Building WP8 ApplicationsWindows Phone 8 - 3 Building WP8 Applications
Windows Phone 8 - 3 Building WP8 Applications
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
 
Introduction to Angular JS
Introduction to Angular JSIntroduction to Angular JS
Introduction to Angular JS
 
Javascript
JavascriptJavascript
Javascript
 
27javascript
27javascript27javascript
27javascript
 
Data binding 入門淺談
Data binding 入門淺談Data binding 入門淺談
Data binding 入門淺談
 
Effective Android Data Binding
Effective Android Data BindingEffective Android Data Binding
Effective Android Data Binding
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2
 

Mehr von Nguyen Tuan

07.Notifications & Reminder, Contact
07.Notifications & Reminder, Contact07.Notifications & Reminder, Contact
07.Notifications & Reminder, ContactNguyen Tuan
 
12.Maps and Location
12.Maps and Location12.Maps and Location
12.Maps and LocationNguyen Tuan
 
11.Open Data Protocol(ODATA)
11.Open Data Protocol(ODATA) 11.Open Data Protocol(ODATA)
11.Open Data Protocol(ODATA) Nguyen Tuan
 
10.Local Database & LINQ
10.Local Database & LINQ10.Local Database & LINQ
10.Local Database & LINQNguyen Tuan
 
09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WPNguyen Tuan
 
08.Push Notifications
08.Push Notifications 08.Push Notifications
08.Push Notifications Nguyen Tuan
 
13.Windows Phone Store
13.Windows Phone Store13.Windows Phone Store
13.Windows Phone StoreNguyen Tuan
 
06.Programming Media on Windows Phone
06.Programming Media on Windows Phone06.Programming Media on Windows Phone
06.Programming Media on Windows PhoneNguyen Tuan
 
05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & AnimationNguyen Tuan
 
03.Controls in Windows Phone
03.Controls in Windows Phone03.Controls in Windows Phone
03.Controls in Windows PhoneNguyen Tuan
 
04.Navigation on Windows Phone
04.Navigation on Windows Phone04.Navigation on Windows Phone
04.Navigation on Windows PhoneNguyen Tuan
 

Mehr von Nguyen Tuan (11)

07.Notifications & Reminder, Contact
07.Notifications & Reminder, Contact07.Notifications & Reminder, Contact
07.Notifications & Reminder, Contact
 
12.Maps and Location
12.Maps and Location12.Maps and Location
12.Maps and Location
 
11.Open Data Protocol(ODATA)
11.Open Data Protocol(ODATA) 11.Open Data Protocol(ODATA)
11.Open Data Protocol(ODATA)
 
10.Local Database & LINQ
10.Local Database & LINQ10.Local Database & LINQ
10.Local Database & LINQ
 
09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP
 
08.Push Notifications
08.Push Notifications 08.Push Notifications
08.Push Notifications
 
13.Windows Phone Store
13.Windows Phone Store13.Windows Phone Store
13.Windows Phone Store
 
06.Programming Media on Windows Phone
06.Programming Media on Windows Phone06.Programming Media on Windows Phone
06.Programming Media on Windows Phone
 
05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation
 
03.Controls in Windows Phone
03.Controls in Windows Phone03.Controls in Windows Phone
03.Controls in Windows Phone
 
04.Navigation on Windows Phone
04.Navigation on Windows Phone04.Navigation on Windows Phone
04.Navigation on Windows Phone
 

Kürzlich hochgeladen

Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...nishasame66
 
Mobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s ToolsMobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s ToolsChandrakantDivate1
 
Android Application Components with Implementation & Examples
Android Application Components with Implementation & ExamplesAndroid Application Components with Implementation & Examples
Android Application Components with Implementation & ExamplesChandrakantDivate1
 
Mobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsMobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsChandrakantDivate1
 
Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312wphillips114
 

Kürzlich hochgeladen (6)

Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
 
Mobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s ToolsMobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s Tools
 
Android Application Components with Implementation & Examples
Android Application Components with Implementation & ExamplesAndroid Application Components with Implementation & Examples
Android Application Components with Implementation & Examples
 
Mobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsMobile Application Development-Components and Layouts
Mobile Application Development-Components and Layouts
 
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
 
Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312
 

02.Designing Windows Phone Application

  • 1. Nguyen Tuan | Microsoft Certified Trainer
  • 2. • Windows Design • Designing an Applications • Working with XAML Layout • Styles & Themes in WP8. • Design Considerations • Model-View-ViewModel • Application Lifecycle Agenda
  • 4. Metro styles or Windows Phone Design Style? • The Windows Phone team have taken a lot of trouble over the look and feel of the phone • They have created a design style, inspired by metropolitan signage, to express this • Programs on the phone should reflect this style 4
  • 5.
  • 6. Take care of the details Make it safe and reliable Uncompromising Sensitivity to Weight, Balance and Scale Align to the grid
  • 7. Principle: Be fast and fluid Life is mobile Delight with motion Design for touch Intuitive interaction Be responsive and ready Immersive and compelling
  • 8. Principles: Do more with less Be great at something Focused and direct Content before chrome Inspire confidence
  • 9. Principle: Authentically Digital Don’t Try to be What It’s NOT Cloud connected Dynamic and alive Beautiful use of typography Bold vibrant colours Motion
  • 10. Principle: Win as one Fit into the UI model Reduce redundancy Work together to complete scenarios Tools and templates are designed to scale
  • 11. Principles Pride in craftsmanship Be Fast and Fluid Win as One Do More with Less Authentically Digital
  • 12.
  • 13. 13
  • 16.
  • 17.
  • 18. 18
  • 19. 19
  • 20. 20
  • 21. 21
  • 22. 22
  • 23. 23
  • 24. 24
  • 26.
  • 27. Pivot Pages • <phone:PhoneApplicationPage x:Class="ContosoCookbook.RecipeDetailPage" ... /> <Grid x:Name="LayoutRoot" Background="Transparent"> <phone:Pivot Title=“PIVOT APPLICATION"> <!--Pivot item one--> <phone:PivotItem Header=“item1"> <Grid> </Grid> </phone:PivotItem> <!--Pivot item two--> <phone:PivotItem Header=“item2"> <Grid> </Grid> </phone:PivotItem> </phone:Pivot> </Grid> </phone:PhoneApplicationPage> 27 Pivot Control Pivot Headers Pivot Items Control
  • 28.
  • 29. 29
  • 30. 30
  • 31. XAML Element Class Hierarchy • The XAML class hierarchy is quite complex • Everything is based on the FrameworkElement class which contains the fundamental properties of all elements • You can derive your own components if you wish 31 FrameworkElement TextBlock TextBox ContentControl ButtonBase Button Control
  • 32. Elements and XAML 32 <!--Pivot item one--> <phone:PivotItem Header="recipe"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="240"/> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Image x:Name="RecipeImage" Stretch="UniformToFill"/> <ScrollViewer Grid.Row="1"> <TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap" /> </ScrollViewer> <StackPanel Grid.Row="2" Orientation="Horizontal"> <TextBlock Text="Prep time: " /> <TextBlock MinWidth="200" x:Name="PrepTimeTextBlock" /> </StackPanel> </Grid> </phone:PivotItem>
  • 33. Grid Container Element 33 <!--Pivot item one--> <phone:PivotItem Header="recipe"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="240"/> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Image x:Name="RecipeImage" Stretch="UniformToFill"/> <ScrollViewer Grid.Row="1"> <TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap" /> </ScrollViewer> <StackPanel Grid.Row="2" Orientation="Horizontal" > <TextBlock Text="Prep time: " /> <TextBlock MinWidth="200" x:Name="PrepTimeTextBlock" /> </StackPanel> </Grid> </phone:PivotItem>
  • 35. • Button at bottom of Designer window can be used to show a 12px alignment Grid • Useful for setting alignment of elements • Available in Blend • Now also available in Visual Studio Visual Studio and Blend Alignment Grid 8/16/2014 35
  • 36. • All new projects include AlignmentGrid.png in the Assets folder • You can overlay the grid at design and runtime by uncommenting the XAML that shows it • Included near the foot of MainPage.xaml • Copy to other pages to show on those <!--Uncomment to see an alignment grid to help ensure your controls are aligned on common boundaries. The image has a top margin of -32px to account for the System Tray. Set this to 0 (or remove the margin altogether) if the System Tray is hidden. Before shipping remove this XAML and the image itself.--> <!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />--> Alignment Grid Overlay 36
  • 37. Using the Alignment Grid 8/16/2014 37 <Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />
  • 38. <phone:PivotItem Header="recipe"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="240"/> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Image x:Name="RecipeImage" Margin="12" Stretch="UniformToFill"/> <ScrollViewer Grid.Row="1"> <TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap" Margin="12,0,0,0" /> </ScrollViewer> <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="12" HorizontalAlignment="Left" > <TextBlock Text="Prep time: " Margin="0" /> <TextBlock x:Name="PrepTimeTextBlock" /> </StackPanel> </Grid> </phone:PivotItem> Use Margin Property to Insert Spacing 38
  • 41. • You can set colors and font sizes for elements directly in XAML: <ScrollViewer Grid.Row="1"> <TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap" Margin="12,0,0,0" Foreground="White" FontSize="12" /> </ScrollViewer> <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="12" HorizontalAlignment="Left" > <TextBlock Text="Prep time: " Margin="0" Foreground="White"/> <TextBlock x:Name="PrepTimeTextBlock" Foreground="LightGray" FontSize="24" /> </StackPanel> • This is generally a BAD IDEA! • Difficult to match builtin styles • Difficult to work with Windows Phone Themes Applying Styles to Elements 8/16/2014 41
  • 42. Foreground Colors and Themes 8/16/2014 42
  • 43. <phone:PivotItem Header="recipe"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="240"/> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Image x:Name="RecipeImage" Margin="12" Stretch="UniformToFill"/> <ScrollViewer Grid.Row="1"> <TextBlock x:Name="DirectionsTextBlock" TextWrapping="Wrap" Margin="12,0,0,0" Style="{StaticResource PhoneTextSmallStyle}" /> </ScrollViewer> <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="12" HorizontalAlignment="Left" > <TextBlock Text="Prep time: " Margin="0" Style="{StaticResource PhoneTextNormalStyle}" /> <TextBlock x:Name="PrepTimeTextBlock" Style="{StaticResource PhoneTextSubtleStyle}" /> </StackPanel> </Grid> </phone:PivotItem> Use Built-In Styles 43
  • 44. New in VS2012 – Apply Styles in Visual Studio 8/16/2014 44
  • 50. Commands “Point of entry” for a method Can be data bound ICommand interface Execute method CanExecute method CanExecuteChanged event
  • 51. Implementing commands It’s quite a lot of work Most toolkits and frameworks have a “relay” implementation RelayCommand (MVVM Light) DelegateCommand (PRISM) …
  • 52. Why MVVM? Model public class KittenObject { public KittenObject() { } public string KittenImage { get; set; } public string KittenName { get; set; } public string KittenAge { get; set; } }
  • 53. Why MVVM? ViewModel public class MainViewModel : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(String propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (null != handler) { handler(this, new PropertyChangedEventArgs(propertyName)); } } }
  • 54. Why MVVM? ViewModel private string _sampleProperty = "my start value"; public string SampleProperty { get { return _sampleProperty; } set { _sampleProperty = value; NotifyPropertyChanged("SampleProperty"); } }
  • 55. Why MVVM? View <TextBlock Text="{Binding SampleProperty, Mode=TwoWay}" />
  • 58. Data Binding Modes • The Mode property determines how changes are synchronized between the target control and data source • OneTime – Control property is set once to the data value and any subsequent changes are ignored • OneWay – Changes in the data object are synchronized to the control property, but changes in the control are not synchronized back to the data object • TwoWay – Changes in the data object are synchronized to the control property and vice-versa <TextBlock x:Name="ContentText" Text="{Binding LineThree, Mode=OneWay}"/>
  • 59. • In the XAML snippet, make sure that the DataContext is set to an instance of the ViewModel class. • The ViewModel class exposes an AddCommand property of type AddItemCommand • The ViewModel is responsible for actually adding a new item Commands <Button Command="{Binding AddCommand}" CommandParameter="Untitled" Content="Button" HorizontalAlignment="Center" VerticalAlignment="Center"/> class AddItemCommand : ICommand { ViewModel _viewModel; public AddItemCommand(ViewModel viewModel) { _viewModel = viewModel; } public event EventHandler CanExecuteChanged; public bool CanExecute(object parameter) { return true; } public void Execute(object title) { _viewModel.AddItem(title as string); } }
  • 60. MVVM Benefits • Reuse Model and View-Model code • Test the ViewModel with unit tests • Maintainability • Can show design-time data in Expression Blend and the Visual Studio designer
  • 63.
  • 68. Tombstoned Not running Running LaunchingClosing DeactivatingActivating Dormant Tombstoned or Dormant? private void Application_Activated(object sender, ActivatedEventArgs e) { if (e.IsApplicationInstancePreserved) { // Dormant - objects in memory intact } else { // Tombstoned - need to reload } }
  • 69. Fast Application Resume Tombstoned Not running Running LaunchingClosing DeactivatingActivating Dormant
  • 70. Enabling FAR in PropertiesWMAppManifest.xml <Tasks> <DefaultTask Name ="_default" NavigationPage="MainPage.xaml"> <BackgroundExecution> <ExecutionType Name="LocationTracking" /> </BackgroundExecution> </DefaultTask> </Tasks> <Tasks> <DefaultTask Name ="_default“ NavigationPage="MainPage.xaml“ /> </Tasks>
  • 71. Why Not Use FAR All The Time? Launch from Start Page 1 Page 2 Launch from Start Page 2deep link
  • 72. Why Not Use FAR All The Time? Launch from Start Page 1 Page 2 Launch from Start Page 2FARPage 1
  • 74. Review • Windows Phone Design has five key principles: • Clean, Light, Open, Fast • Celebrate Typography • Alive in Motion • Content, Not Chrome • Authentically Digital • WP8 use XAML to express the design of their user interface • The design is expressed in a XAML text file that defines and arranges display elements • There are a set of project templates for applications based on the Windows Phone design • In Blend, you can create design-time data to aid during design of a UI • Databinding in XAML allows you to declaratively markup UI elements to link them to a property of a data class • List controls define layout using XAML Templates