SlideShare a Scribd company logo
1 of 53
Download to read offline
Building Windows Phone
Applications
Nguyen Tuan | Microsoft Certified Trainer
Agenda
• Controls:
• Border.
• Button.
• Canvas.
• Checkbox.
• RadioButton.
• HyperlinkButton.
• TextBox.
• PasswordBox.
• TextBlock.
• Lists, List Items:
• Lists and List Items
• List Controls and capabilities
• Creating list items
• Grouped lists and grouping navigation
• Long lists and best practices
controls
Controls
• Reusable units for presentation
• Defined UI/Interaction patterns
• Input
• Feedback
• Consistency with OS
• Familiarity to the user
Content model
• ContentControl
• ButtonBase
• Button, RepeatButton, ToggleButton  RadioButton, CheckBox
• UserControl
• ItemsControl
• ListBox, DataGrid, TreeView, ToolBar, TabControl, GridView (Win8),
ListView
Core Controls
ToggleSwitch
CheckBox
Button
Hyperlink Button
Radio buttons
ProgressBar
(indeterminate)
ProgressBar
(determinate)
ProgressRing
Slider
Core Controls (part 2 )
TextBox
PasswordBox
TextBox
(Multiline)
ComboBox
(with header)
ListBox
Image
Popup
Core Controls (part 3 )
Date & Time pickers
WebView
styles and templates
A collection of property values
• Grouped in a Style object
• Usually defined as a resource
Styles
Styles
<Style />
This is a text
And another
Extending Styles (BasedOn)
Lookless Controls
Controls have behavior
Visuals separate from implementation
• Defined in Xaml
• Defined by a designer
• Controls usually have a default “style”
Templates
TemplateBinding
• Template should honor control properties
• Background, Padding, etc.
• TemplateBinding connects properties
• Projects control properties onto the screen
UserControl
• Logical grouping of items.
• Can be reused.
• Has XAML front end and code-behind.
Demo:
PhoneToolkitSample
visual state manager
Visual States
[TemplateVisualState(GroupName = "CommonStates", Name = "Pressed")]
[TemplateVisualState(GroupName = "CommonStates", Name = "MouseOver")]
[TemplateVisualState(GroupName = "CommonStates", Name = "Normal")]
[TemplateVisualState(GroupName = "CommonStates", Name = "Disabled")]
[TemplateVisualState(GroupName = "FocusStates", Name = "Unfocused")]
[TemplateVisualState(GroupName = "FocusStates", Name = "Focused")]
public class Button : ButtonBase
{
…
}
Visual states
Click
VisualStateManager
• ListView
• GridView
• ListBox (last resort)
Controls for Lists of Things
ListView
• Vertical list of items
• Good for:
• Simple lists
• Grouped lists
GridView
• Grid of items
• Usually image-based items
List Control Templates
• HeaderTemplate
• FooterTemplate
• ItemTemplate
• ItemContainerStyle
• ItemsPanel
• GroupStyle
• ContainerStyle
• HeaderTemplate
List Headers and Footers
• HeaderTemplate displays at top of list
• FooterTemplate displays at bottom of list
• Scroll with list content (not sticky)
Reference:
http://msdn.microsoft.com/en-us/library/windows/apps/hh465319.aspx
List Item Templates
• ItemTemplate
• displays item data
List Item Templates
• ItemTemplate
• displays item data
• ItemContainerStyle
• displays item state
List Item Templates
• ItemTemplate
• displays item data
• ItemContainerStyle
• displays item state
• ItemsPanel
• manages item-by-item layout
<ItemsPanelTemplate x:Key="SampleItemsPanel">
<ItemsStackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
<ItemsPanelTemplate x:Key="SampleItemsPanel">
<ItemsWrapGrid Orientation=“Horizontal" />
</ItemsPanelTemplate>
Reordering
• Items shift into floating UI
• Reordered with Tap-Hold + Drag
• Windows Phone
• Windows
• Grouped Lists cannot be reordered
MyListView.ReorderMode = ListViewReorderMode.Enabled;
MyListView.CanReorderItems = false;
MultiSelection
• Displays checkboxes for multi-selection
MyListView.SelectionMode =
ListViewSelectionMode.Multiple;
Grouping Data
• Grouping requires data as a
CollectionViewSource
• Or a list of lists (no JumpList)
37
Grouping Data
• JumpLists Require
- KeyedList
• or
- AlphaKeyGroup
Grouping Data – KeyedList
- Start with a list of data
- Use a KeyedList class
- Format the data using the following
LINQ query
var groupedItems =
from item in items
orderby item.SortProperty
group item by item.SortProperty into itemsByProperty
select new KeyedList<string, MyObject>(itemsByProperty);
List<KeyedList<string, SampleItem>> KeyedList = groupedItems.ToList();
Grouping Data – AlphaKeyGroup
- Start with a list of data
- Create an AlphaKeyGroup class
- Create grouping with:
var alphaKeyGroup = AlphaKeyGroup<SampleItem>.CreateGroups(
items, // basic list of items
(SampleItem s) => { return s.Title; }, // the property to sort
true); // order the items
// returns type List<AlphaKeyGroup<SampleItem>>
Grouping Data – CollectionViewSource
• Set DataContext to your page
• Place a CollectionViewSource in the Resources:
<CollectionViewSource
x:Key="ItemsGrouped"
IsSourceGrouped="True"
ItemsPath="InternalList"
Source="{Binding MyKeyedList, Source={Binding}}"/>
<ListView ItemsSource="{Binding Source={StaticResource ItemsGrouped}}" />
Grouping List UI
• Grouping Style and Template
<ListView.GroupStyle>
<GroupStyle HidesIfEmpty="True" >
<GroupStyle.HeaderTemplate>
…
<TextBlock Text="{Binding Key}" />
…
<GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
Grouping List Navigation
• Semntic Zoom
<SemanticZoom>
<SemanticZoom.ZoomedInView>
<!-- ListView or GridView -->
<!-- ItemsSource binds to
CollectionViewSource -->
</SemanticZoom.ZoomedInView>
<SemanticZoom.ZoomedOutView>
<!-- ListView or GridView -->
<!-- ItemsSource bound to
CollectionViewSource,
Path=CollectionGroups -->
</SemanticZoom.ZoomedOutView>
</SemanticZoom>
• ZoomedInView – default view
• ZoomedOutView
• triggered by group item interaction
• overlays the screen (Flyout)
• transparent background
Semantic Zoom Design
Reference:
http://msdn.microsoft.com/en-us/library/windows/apps/hh465319.aspx
Group layouts are virtualized
List controls renders elements near the viewport
Item Rendering and Group Virtualization
Progressive Item Rendering
Sed nec sodale
Alpine Ski House
Sed nec sodale
Alpine Ski House
ContainerContentChanging
Fires when item is realized
Items can be rendered in phases
<ListView ItemTemplate="{StaticResource SampleDataTemplate}"
ContainerContentChanging="IncrementalUpdateHandler" >
private void IncrementalUpdateHandler(ListViewBase sender, ContainerContentChangingEventArgs
args)
{
args.Handled = true;
if (args.Phase != 0)
throw new Exception("we will always be in phase 0");
else
{
// show a placeholder shape
args.RegisterUpdateCallback(ShowText);
}
}
ContainerContentChanging
Later phases will be skipped if too much time is needed
private void ShowText(ListViewBase sender, ContainerContentChangingEventArgs args)
{
args.Handled = true;
if (args.Phase != 1)
throw new Exception("we should always be in phase 1");
else
{
// show text from the template
args.RegisterUpdateCallback(ShowImage);
}
}
Phase priorities
1. Simple shapes (placeholder visuals)
2. Key text (title)
3. Other text (subtitle)
4. Images
Performance tip
Do not use Visibility to show/hide UIElements
this will fire a new ContainerContentChanging event
Instead, use “Opacity=0”
References
• http://msdn.microsoft.com/en-
us/library/windowsphone/develop/jj735581%28v=vs.105%29.aspx
• http://msdn.microsoft.com/en-
us/library/windows/apps/windows.ui.xaml.controls.semanticzoom.aspx

More Related Content

Viewers also liked

Spectrum Auctions for iWeek South Africa KB Enterprises
Spectrum Auctions for iWeek South Africa KB EnterprisesSpectrum Auctions for iWeek South Africa KB Enterprises
Spectrum Auctions for iWeek South Africa KB EnterprisesKB Enterprises LLC
 
Transport Issues in Adelaide | Biocity Studio
Transport Issues in Adelaide | Biocity StudioTransport Issues in Adelaide | Biocity Studio
Transport Issues in Adelaide | Biocity StudioBiocity Studio
 
19.10.2009, Vindmølleindustrien: Indsigelse Akt nr. 48 drift, 7 møller af 250...
19.10.2009, Vindmølleindustrien: Indsigelse Akt nr. 48 drift, 7 møller af 250...19.10.2009, Vindmølleindustrien: Indsigelse Akt nr. 48 drift, 7 møller af 250...
19.10.2009, Vindmølleindustrien: Indsigelse Akt nr. 48 drift, 7 møller af 250...is gone
 
Going Beyond Parallel Play - How to Take Integrated Programs to the Next Level
Going Beyond Parallel Play - How to Take Integrated Programs to the Next LevelGoing Beyond Parallel Play - How to Take Integrated Programs to the Next Level
Going Beyond Parallel Play - How to Take Integrated Programs to the Next LevelCharity Dynamics
 
Unit 6c Health insurance
Unit 6c Health insuranceUnit 6c Health insurance
Unit 6c Health insuranceAndrew Hingston
 
BBcon 2014 Moneyball: How Analytics Improves Fundraising
BBcon 2014 Moneyball: How Analytics Improves FundraisingBBcon 2014 Moneyball: How Analytics Improves Fundraising
BBcon 2014 Moneyball: How Analytics Improves FundraisingCharity Dynamics
 
Разработка современной электроники с прицелом на массовый выпуск. На чем?
Разработка современной электроники с прицелом на массовый выпуск. На чем?Разработка современной электроники с прицелом на массовый выпуск. На чем?
Разработка современной электроники с прицелом на массовый выпуск. На чем?Ingria. Technopark St. Petersburg
 
02.Designing Windows Phone Application
02.Designing Windows Phone Application02.Designing Windows Phone Application
02.Designing Windows Phone ApplicationNguyen Tuan
 
TWTRCON NY 10 Case Study: Dell's Evolving Use of Twitter | Stefanie Nelson, D...
TWTRCON NY 10 Case Study: Dell's Evolving Use of Twitter | Stefanie Nelson, D...TWTRCON NY 10 Case Study: Dell's Evolving Use of Twitter | Stefanie Nelson, D...
TWTRCON NY 10 Case Study: Dell's Evolving Use of Twitter | Stefanie Nelson, D...Edelman
 
Låt analysen driva Er digitala transformation!
Låt analysen driva Er digitala transformation!Låt analysen driva Er digitala transformation!
Låt analysen driva Er digitala transformation!Mattias Malmnäs
 
11.Open Data Protocol(ODATA)
11.Open Data Protocol(ODATA) 11.Open Data Protocol(ODATA)
11.Open Data Protocol(ODATA) Nguyen Tuan
 
Akademi Klasik Türk Müziği Korosu 2016 Ocak 18 Konseri resimleri
Akademi Klasik Türk Müziği Korosu 2016 Ocak 18 Konseri resimleriAkademi Klasik Türk Müziği Korosu 2016 Ocak 18 Konseri resimleri
Akademi Klasik Türk Müziği Korosu 2016 Ocak 18 Konseri resimleriaokutur
 

Viewers also liked (20)

Spectrum Auctions for iWeek South Africa KB Enterprises
Spectrum Auctions for iWeek South Africa KB EnterprisesSpectrum Auctions for iWeek South Africa KB Enterprises
Spectrum Auctions for iWeek South Africa KB Enterprises
 
Transport Issues in Adelaide | Biocity Studio
Transport Issues in Adelaide | Biocity StudioTransport Issues in Adelaide | Biocity Studio
Transport Issues in Adelaide | Biocity Studio
 
19.10.2009, Vindmølleindustrien: Indsigelse Akt nr. 48 drift, 7 møller af 250...
19.10.2009, Vindmølleindustrien: Indsigelse Akt nr. 48 drift, 7 møller af 250...19.10.2009, Vindmølleindustrien: Indsigelse Akt nr. 48 drift, 7 møller af 250...
19.10.2009, Vindmølleindustrien: Indsigelse Akt nr. 48 drift, 7 møller af 250...
 
UDV 2016 Final
UDV 2016 FinalUDV 2016 Final
UDV 2016 Final
 
Going Beyond Parallel Play - How to Take Integrated Programs to the Next Level
Going Beyond Parallel Play - How to Take Integrated Programs to the Next LevelGoing Beyond Parallel Play - How to Take Integrated Programs to the Next Level
Going Beyond Parallel Play - How to Take Integrated Programs to the Next Level
 
Muniport
MuniportMuniport
Muniport
 
Inbound Marketing Workshop - Introduction
Inbound Marketing Workshop - IntroductionInbound Marketing Workshop - Introduction
Inbound Marketing Workshop - Introduction
 
Unit 6c Health insurance
Unit 6c Health insuranceUnit 6c Health insurance
Unit 6c Health insurance
 
Flaphone
FlaphoneFlaphone
Flaphone
 
Cloud Mach
Cloud MachCloud Mach
Cloud Mach
 
BBcon 2014 Moneyball: How Analytics Improves Fundraising
BBcon 2014 Moneyball: How Analytics Improves FundraisingBBcon 2014 Moneyball: How Analytics Improves Fundraising
BBcon 2014 Moneyball: How Analytics Improves Fundraising
 
Стратегия лидерства
Стратегия лидерстваСтратегия лидерства
Стратегия лидерства
 
Разработка современной электроники с прицелом на массовый выпуск. На чем?
Разработка современной электроники с прицелом на массовый выпуск. На чем?Разработка современной электроники с прицелом на массовый выпуск. На чем?
Разработка современной электроники с прицелом на массовый выпуск. На чем?
 
Electonic tongue
Electonic tongueElectonic tongue
Electonic tongue
 
悲劇和記者
悲劇和記者悲劇和記者
悲劇和記者
 
02.Designing Windows Phone Application
02.Designing Windows Phone Application02.Designing Windows Phone Application
02.Designing Windows Phone Application
 
TWTRCON NY 10 Case Study: Dell's Evolving Use of Twitter | Stefanie Nelson, D...
TWTRCON NY 10 Case Study: Dell's Evolving Use of Twitter | Stefanie Nelson, D...TWTRCON NY 10 Case Study: Dell's Evolving Use of Twitter | Stefanie Nelson, D...
TWTRCON NY 10 Case Study: Dell's Evolving Use of Twitter | Stefanie Nelson, D...
 
Låt analysen driva Er digitala transformation!
Låt analysen driva Er digitala transformation!Låt analysen driva Er digitala transformation!
Låt analysen driva Er digitala transformation!
 
11.Open Data Protocol(ODATA)
11.Open Data Protocol(ODATA) 11.Open Data Protocol(ODATA)
11.Open Data Protocol(ODATA)
 
Akademi Klasik Türk Müziği Korosu 2016 Ocak 18 Konseri resimleri
Akademi Klasik Türk Müziği Korosu 2016 Ocak 18 Konseri resimleriAkademi Klasik Türk Müziği Korosu 2016 Ocak 18 Konseri resimleri
Akademi Klasik Türk Müziği Korosu 2016 Ocak 18 Konseri resimleri
 

Similar to 04.Navigation on Windows Phone

Windows 8 Design with Gridview
Windows 8 Design with GridviewWindows 8 Design with Gridview
Windows 8 Design with GridviewJeff Klawiter
 
05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & AnimationNguyen Tuan
 
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...SPTechCon
 
cake phptutorial
cake phptutorialcake phptutorial
cake phptutorialice27
 
Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010Rob Windsor
 
Hibernate Tutorial for beginners
Hibernate Tutorial for beginnersHibernate Tutorial for beginners
Hibernate Tutorial for beginnersrajkamal560066
 
Iniciando com jquery
Iniciando com jqueryIniciando com jquery
Iniciando com jqueryDanilo Sousa
 
Oracle 10g Forms Lesson 6
Oracle 10g Forms Lesson  6Oracle 10g Forms Lesson  6
Oracle 10g Forms Lesson 6KAMA3
 
Oracle Forms Creation part 3
Oracle Forms Creation part 3Oracle Forms Creation part 3
Oracle Forms Creation part 3Sekhar Byna
 
SharePointfest Denver - A jQuery Primer for SharePoint
SharePointfest Denver -  A jQuery Primer for SharePointSharePointfest Denver -  A jQuery Primer for SharePoint
SharePointfest Denver - A jQuery Primer for SharePointMarc D Anderson
 
Applied component i unit 2
Applied component i unit 2Applied component i unit 2
Applied component i unit 2Pramod Redekar
 
9781305078444 ppt ch05
9781305078444 ppt ch059781305078444 ppt ch05
9781305078444 ppt ch05Terry Yoast
 
Caffeinated Style Sheets
Caffeinated Style SheetsCaffeinated Style Sheets
Caffeinated Style SheetsTommy Hodgins
 
SharePoint TechCon 2009 - 907
SharePoint TechCon 2009 - 907SharePoint TechCon 2009 - 907
SharePoint TechCon 2009 - 907Andreas Grabner
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans Fabrizio Giudici
 

Similar to 04.Navigation on Windows Phone (20)

Windows 8 Design with Gridview
Windows 8 Design with GridviewWindows 8 Design with Gridview
Windows 8 Design with Gridview
 
05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation
 
Angular JS
Angular JSAngular JS
Angular JS
 
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 3: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
 
cake phptutorial
cake phptutorialcake phptutorial
cake phptutorial
 
Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010
 
Hibernate Tutorial for beginners
Hibernate Tutorial for beginnersHibernate Tutorial for beginners
Hibernate Tutorial for beginners
 
wt mod2.pdf
wt mod2.pdfwt mod2.pdf
wt mod2.pdf
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Iniciando com jquery
Iniciando com jqueryIniciando com jquery
Iniciando com jquery
 
Oracle 10g Forms Lesson 6
Oracle 10g Forms Lesson  6Oracle 10g Forms Lesson  6
Oracle 10g Forms Lesson 6
 
Les06
Les06Les06
Les06
 
Oracle Forms Creation part 3
Oracle Forms Creation part 3Oracle Forms Creation part 3
Oracle Forms Creation part 3
 
SharePointfest Denver - A jQuery Primer for SharePoint
SharePointfest Denver -  A jQuery Primer for SharePointSharePointfest Denver -  A jQuery Primer for SharePoint
SharePointfest Denver - A jQuery Primer for SharePoint
 
Applied component i unit 2
Applied component i unit 2Applied component i unit 2
Applied component i unit 2
 
9781305078444 ppt ch05
9781305078444 ppt ch059781305078444 ppt ch05
9781305078444 ppt ch05
 
Caffeinated Style Sheets
Caffeinated Style SheetsCaffeinated Style Sheets
Caffeinated Style Sheets
 
SharePoint TechCon 2009 - 907
SharePoint TechCon 2009 - 907SharePoint TechCon 2009 - 907
SharePoint TechCon 2009 - 907
 
Wpf Introduction
Wpf IntroductionWpf Introduction
Wpf Introduction
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans
 

More from 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
 
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
 
03.Controls in Windows Phone
03.Controls in Windows Phone03.Controls in Windows Phone
03.Controls in Windows PhoneNguyen Tuan
 

More from Nguyen Tuan (8)

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
 
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
 
03.Controls in Windows Phone
03.Controls in Windows Phone03.Controls in Windows Phone
03.Controls in Windows Phone
 

04.Navigation on Windows Phone

  • 1. Building Windows Phone Applications Nguyen Tuan | Microsoft Certified Trainer
  • 2. Agenda • Controls: • Border. • Button. • Canvas. • Checkbox. • RadioButton. • HyperlinkButton. • TextBox. • PasswordBox. • TextBlock. • Lists, List Items: • Lists and List Items • List Controls and capabilities • Creating list items • Grouped lists and grouping navigation • Long lists and best practices
  • 4. Controls • Reusable units for presentation • Defined UI/Interaction patterns • Input • Feedback • Consistency with OS • Familiarity to the user
  • 5. Content model • ContentControl • ButtonBase • Button, RepeatButton, ToggleButton  RadioButton, CheckBox • UserControl • ItemsControl • ListBox, DataGrid, TreeView, ToolBar, TabControl, GridView (Win8), ListView
  • 6. Core Controls ToggleSwitch CheckBox Button Hyperlink Button Radio buttons ProgressBar (indeterminate) ProgressBar (determinate) ProgressRing Slider
  • 7. Core Controls (part 2 ) TextBox PasswordBox TextBox (Multiline) ComboBox (with header) ListBox Image Popup
  • 8. Core Controls (part 3 ) Date & Time pickers WebView
  • 9.
  • 11. A collection of property values • Grouped in a Style object • Usually defined as a resource Styles
  • 12. Styles <Style /> This is a text And another
  • 14. Lookless Controls Controls have behavior Visuals separate from implementation • Defined in Xaml • Defined by a designer • Controls usually have a default “style”
  • 16.
  • 17. TemplateBinding • Template should honor control properties • Background, Padding, etc. • TemplateBinding connects properties • Projects control properties onto the screen
  • 18. UserControl • Logical grouping of items. • Can be reused. • Has XAML front end and code-behind.
  • 21. Visual States [TemplateVisualState(GroupName = "CommonStates", Name = "Pressed")] [TemplateVisualState(GroupName = "CommonStates", Name = "MouseOver")] [TemplateVisualState(GroupName = "CommonStates", Name = "Normal")] [TemplateVisualState(GroupName = "CommonStates", Name = "Disabled")] [TemplateVisualState(GroupName = "FocusStates", Name = "Unfocused")] [TemplateVisualState(GroupName = "FocusStates", Name = "Focused")] public class Button : ButtonBase { … }
  • 24.
  • 25. • ListView • GridView • ListBox (last resort) Controls for Lists of Things
  • 26. ListView • Vertical list of items • Good for: • Simple lists • Grouped lists
  • 27. GridView • Grid of items • Usually image-based items
  • 28. List Control Templates • HeaderTemplate • FooterTemplate • ItemTemplate • ItemContainerStyle • ItemsPanel • GroupStyle • ContainerStyle • HeaderTemplate
  • 29. List Headers and Footers • HeaderTemplate displays at top of list • FooterTemplate displays at bottom of list • Scroll with list content (not sticky) Reference: http://msdn.microsoft.com/en-us/library/windows/apps/hh465319.aspx
  • 30. List Item Templates • ItemTemplate • displays item data
  • 31. List Item Templates • ItemTemplate • displays item data • ItemContainerStyle • displays item state
  • 32. List Item Templates • ItemTemplate • displays item data • ItemContainerStyle • displays item state • ItemsPanel • manages item-by-item layout <ItemsPanelTemplate x:Key="SampleItemsPanel"> <ItemsStackPanel Orientation="Vertical" /> </ItemsPanelTemplate> <ItemsPanelTemplate x:Key="SampleItemsPanel"> <ItemsWrapGrid Orientation=“Horizontal" /> </ItemsPanelTemplate>
  • 33.
  • 34. Reordering • Items shift into floating UI • Reordered with Tap-Hold + Drag • Windows Phone • Windows • Grouped Lists cannot be reordered MyListView.ReorderMode = ListViewReorderMode.Enabled; MyListView.CanReorderItems = false;
  • 35. MultiSelection • Displays checkboxes for multi-selection MyListView.SelectionMode = ListViewSelectionMode.Multiple;
  • 36.
  • 37. Grouping Data • Grouping requires data as a CollectionViewSource • Or a list of lists (no JumpList) 37
  • 38. Grouping Data • JumpLists Require - KeyedList • or - AlphaKeyGroup
  • 39. Grouping Data – KeyedList - Start with a list of data - Use a KeyedList class - Format the data using the following LINQ query var groupedItems = from item in items orderby item.SortProperty group item by item.SortProperty into itemsByProperty select new KeyedList<string, MyObject>(itemsByProperty); List<KeyedList<string, SampleItem>> KeyedList = groupedItems.ToList();
  • 40. Grouping Data – AlphaKeyGroup - Start with a list of data - Create an AlphaKeyGroup class - Create grouping with: var alphaKeyGroup = AlphaKeyGroup<SampleItem>.CreateGroups( items, // basic list of items (SampleItem s) => { return s.Title; }, // the property to sort true); // order the items // returns type List<AlphaKeyGroup<SampleItem>>
  • 41. Grouping Data – CollectionViewSource • Set DataContext to your page • Place a CollectionViewSource in the Resources: <CollectionViewSource x:Key="ItemsGrouped" IsSourceGrouped="True" ItemsPath="InternalList" Source="{Binding MyKeyedList, Source={Binding}}"/> <ListView ItemsSource="{Binding Source={StaticResource ItemsGrouped}}" />
  • 42. Grouping List UI • Grouping Style and Template <ListView.GroupStyle> <GroupStyle HidesIfEmpty="True" > <GroupStyle.HeaderTemplate> … <TextBlock Text="{Binding Key}" /> … <GroupStyle.HeaderTemplate> </GroupStyle> </ListView.GroupStyle>
  • 43. Grouping List Navigation • Semntic Zoom <SemanticZoom> <SemanticZoom.ZoomedInView> <!-- ListView or GridView --> <!-- ItemsSource binds to CollectionViewSource --> </SemanticZoom.ZoomedInView> <SemanticZoom.ZoomedOutView> <!-- ListView or GridView --> <!-- ItemsSource bound to CollectionViewSource, Path=CollectionGroups --> </SemanticZoom.ZoomedOutView> </SemanticZoom>
  • 44. • ZoomedInView – default view • ZoomedOutView • triggered by group item interaction • overlays the screen (Flyout) • transparent background Semantic Zoom Design Reference: http://msdn.microsoft.com/en-us/library/windows/apps/hh465319.aspx
  • 45.
  • 46.
  • 47. Group layouts are virtualized List controls renders elements near the viewport Item Rendering and Group Virtualization
  • 48. Progressive Item Rendering Sed nec sodale Alpine Ski House Sed nec sodale Alpine Ski House
  • 49. ContainerContentChanging Fires when item is realized Items can be rendered in phases <ListView ItemTemplate="{StaticResource SampleDataTemplate}" ContainerContentChanging="IncrementalUpdateHandler" > private void IncrementalUpdateHandler(ListViewBase sender, ContainerContentChangingEventArgs args) { args.Handled = true; if (args.Phase != 0) throw new Exception("we will always be in phase 0"); else { // show a placeholder shape args.RegisterUpdateCallback(ShowText); } }
  • 50. ContainerContentChanging Later phases will be skipped if too much time is needed private void ShowText(ListViewBase sender, ContainerContentChangingEventArgs args) { args.Handled = true; if (args.Phase != 1) throw new Exception("we should always be in phase 1"); else { // show text from the template args.RegisterUpdateCallback(ShowImage); } }
  • 51. Phase priorities 1. Simple shapes (placeholder visuals) 2. Key text (title) 3. Other text (subtitle) 4. Images
  • 52. Performance tip Do not use Visibility to show/hide UIElements this will fire a new ContainerContentChanging event Instead, use “Opacity=0”