Professional Documents
Culture Documents
The Goal
Investigate different ways of laying out Metro style applications Work with controls, including styling Try out several of the basic controls Add app bars, flyouts, and context menus
Metro style applications supply a number of different surfaces onto which you can add user interface elements
App window App bars Popups
Dialogs
built-in animations
built-in animations
App Bar
Secondary to app window
App Bar is primary command interface Replaces menus
App Bar
Secondary to app window
App Bar is primary command interface Replaces menus
Charms Bar
Presents specific and consistent set of buttons, the same in every app
Search Share Connect Settings Start
Charms Bar
Can appear to the right of the screen (if using a touch screen)
Can use win+c key to display, or hover in lower right-
hand corner
Charms Bar
Can appear to the right of the screen (if using a touch screen)
Can use win+c key to display, or hover in lower right-
hand corner
Context Menus
Also called popup menu Shows actions users can perform on text or UI elements Can use up to five (and no more) commands on each context menu
Like cut, copy, open with
Limit keeps menus uncluttered
Context Menus
Also called popup menu Shows actions users can perform on text or UI elements Can use up to five (and no more) commands on each context menu
Like cut, copy, open with
Limit keeps menus uncluttered
Message Dialogs
Modal dialogs that require explicit user interaction Dim the app window
Demand response before continuing
Use message dialogs only when the intent is to stop the user and demand a response
Message Dialogs
Modal dialogs that require explicit user interaction Dim the app window
Demand response before continuing
Use message dialogs only when the intent is to stop the user and demand a response
Flyouts
Flyouts
Toasts
Notifications to indicate activity to user when app is in background Great for real-time update without requiring app in foreground
OK if user misses the information
Users tap on the toast to switch to your app and learn more
Errors
Different kinds of errors require different kinds of user interface App developer chooses surface for error based on content and consequences of the error
bars
bars
Message Dialogs
Message Dialogs
Your goal: Create apps that look good and work well across a variety of
Form factors Display sizes View states
Views
View defines the way your app is accessed and manipulated by a user:
Landscape or portrait orientation Full screen, snapped, or fill view states Pannable, zoomable, scaled or resized UI Specific UI elements
o Search results pane o Folder structure
Handling Views
View describes the way users access and manipulate content Can view app on devices of various sizes and orientations Plan for different view states, screen orientations, and user interaction views
View States
Screen Orientation
Layouts
Mechanisms by which your app can accommodate the views it supports Style, structure, and present app content using CSS layout modules
Grids Multi-columns Connected frames Flexible boxes
CSS provides media features that allow you to determine current media settings
Provides information about the device being used to
Specific media could be something besides screen, but care about screen here feature represents specific feature to test
For example: width:600px Apply rules to screens that are exactly 600px wide
DEMO 1
DEMO 2
Events
So far, nothing happens when you select item in list, or click button Each control provides events enabling you to respond to actions
Button provides click event; raised when clicked
o Create event handler to handle event
Programmatically
o In JavaScript, retrieve reference to control o Call addEventListener method, pass event handler o Preferred method
DEMO 3
reference to the control o If you use declarative hookup, the target property returns reference to the window
DEMO 4
namespaces
JavaScript easier
WinJS Controls
Large set of controls Each abstracted as HTML (and CSS and JavaScript) Provide basis for Metro style applications Following slides introduce most of the WinJS controls
Images from set of Metro style samples from Microsoft
AppBar Control
App toolbar that displays commands Covers application content Appear using edge swipe, Win+Z, or right-click
Dismiss with app interaction, another edge swipe, or
timer
DatePicker Control
FlipView Control
Flyout Control
separate window
ListView Control
Rating Control
SemanticZoom Control
Provides a way to manage and present two semantic views (abstractions) Single set of hierarchical data or content
Folder structure of a computer, a library of
SettingsPane Control
TimePicker Control
Toggle Control
ToolTip Control
ViewBox Control
Scales a single child element to fill the available space without resizing it
Reacts to changes in the size of the container And changes in size of the child element
Unlike HTML controls, WinJS controls don't have dedicated markup elements
Can't create Rating control by adding <rating/> to the
markup
Instead, create <div> element and set data-wincontrol attribute to class name of control
<div data-win-control="WinJS.UI.Rating">
Hooking Things Up
Just creating the <div> elements isn't enough Must also call WinJS.UI.processAll in order to instantiate WinJS controls WinJS.UI.processAll returns a Promise
Put any code that needs to run after the call to
DEMO 5
o data-win-options="{name1:value1, name2:value2}"
DEMO 6
Shortcut
Asynchronous Behavior!
DEMO 7
Retrieve reference in code Set property in code Use shortcut versions as well
DEMO 8
Control Components
Typical control has several sub-parts Text control has two parts: text value and clear button
CSS Pseudo-Elements
Available Parts
Using Pseudo-Elements
Password control provides button to reveal password Make the button green, key white, with dashed red border?
Demo shows how!
DEMO 9
Assign specific class to control to modify its behavior Documentation lists all available classes
<button class="win-backbutton"></button>
o win-datepicker-year
DEMO 10
Built-in style sheets also provide support for specific styles for text
win-type-xx-large win-type-medium win-type-xx-small
DEMO 11
App bar presents navigation, commands, and tools to users App bar appears when user swipes from top or bottom edge of screen
Or when opened programmatically
Covers the bottom and top content of app Dismiss by user with edge swipe
Or by app interaction
DEMO 12
if false, must show or hide in code autoHide: milliseconds before app bar hides lightDismiss: should AppBar hide when user clicks outside of app bar element?
Adding Buttons
Add <button> element, using the WinJS.UI.AppBar setting for data-win-control attribute Set various properties:
id label
DEMO 13
Add a Flyout
Flyouts show content you don't want onscreen all the time
Users open and dismiss flyouts at any time
Useful for:
Collecting information
Displaying warnings/confirmations
Showing drop-down menus Providing more Info
Flyout Guidelines
commands
DEMO 14
Create flyout Create context menu
Covered a little of what it takes to create a User Interface using HTML, JavaScript, and CSS Obviously, tons more
Many more HTML and WinJS controls Lots more details
Any project requiring even simple controls will require some study of the documentation
All these skills expandable to other controls.
Learn More!
This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn more about Metro Style Applications on SlideShare:
Building Windows 8 Metro Style Applications Using JavaScript and HTML5