UWP Adaptive UI

39
Build Adaptive UI’s for Phones, Tablets, Desktops, Xbox, and More James Quick @jamesqquick

Transcript of UWP Adaptive UI

Page 1: UWP Adaptive UI

Build Adaptive UI’s for Phones, Tablets, Desktops, Xbox, and MoreJames Quick@jamesqquick

Page 2: UWP Adaptive UI

AgendaUWP Design PrinciplesWhat Devices Am I Designing For?Design Techniques for Adaptive UIHow to Build an Adaptive UIDemos/Hands On

Page 3: UWP Adaptive UI

Phone Small Tablet

2-in-1s(Tablet or Laptop)

Desktops & All-in-OnesPhablet Large Tablet

Classic Laptop

Xbox IoTSurface Hub

Holographic

Windows 10

Page 4: UWP Adaptive UI

UWP Design Principles

Page 5: UWP Adaptive UI

We want you to use your design, fonts, icons etc…

If you’re stuck, or need inspiration, we share our first party guidance that you can use

Page 6: UWP Adaptive UI

Four is the magic number

Page 7: UWP Adaptive UI

Scaling algorithm

Page 8: UWP Adaptive UI
Page 9: UWP Adaptive UI

Effective pixel

Effective Pixel

Physical Pixel

Page 10: UWP Adaptive UI
Page 11: UWP Adaptive UI

Ignore scale, resolution, & dpi.Design in Effective Pixels

Page 12: UWP Adaptive UI

What Device Am I Designing For?

Page 13: UWP Adaptive UI

Planning your design

PhoneViewing Distance:

16.3”

Tablets and 2 in 1Viewing Distance:

20”

Small and Large Laptops

Viewing Distance:24.5”

Small and Large Desktop Monitors

Viewing Distance:28”

TVViewing Distance:

84”

5”

8”

13”

Page 14: UWP Adaptive UI

Snap points

phablet & tablet

desktopphone548 720 1024320ep

x

Page 15: UWP Adaptive UI

Keep it SimplePhone

(Portrait)Tablet/Desktop

(Landscape)

Page 16: UWP Adaptive UI

Demo: Calculator and Calendar

Page 17: UWP Adaptive UI

As you design

1. Adapt to size change2. Adapt to input change 3. Use Effective Pixels

Page 18: UWP Adaptive UI

Design Techniques for Adaptive UI

Page 19: UWP Adaptive UI

Reposition1

Reveal4

Resize2

Replace5

Reflow3

Re-architect6

Use standard responsive/adaptive design techniques

Page 20: UWP Adaptive UI

Adaptive designBuild a page that adapts to different screen sizes and orientationsVisual States and Adaptive Triggers to change layoutRelativePanel to position blocks relative to each other

Phone (portrait)Tablet (landscape) / Desktop

Page 21: UWP Adaptive UI

Tailored designBuild unique experiences on different devices

Phone (portrait)Tablet (landscape) / Desktop

Page 22: UWP Adaptive UI

Building Tailored ViewsBuild unique experiences on different devices

One option: Build separate pages for individual familiesCan interrogate resource qualifiers (from MRT) to determine the family

Option 2: Use XAML views

var qualifiers = Windows.ApplicationModel.Resources.Core                     .ResourceContext.GetForCurrentView().QualifierValues;

if (qualifiers["DeviceFamily"] == "DeviceFamily-Xbox") // optimized for games console rootFrame.Navigate(typeof(MainPage_Xbox), e.Arguments);else   rootFrame.Navigate(typeof(MainPage), e.Arguments);

Page 23: UWP Adaptive UI

How to build an Adaptive UI

Page 24: UWP Adaptive UI

Visual states allow you to define different selectable layouts that can be applied to your UI

Page 25: UWP Adaptive UI

How to set the visual state in codeVisualStateManager.Goto(element, state, transition)public MainPage(){ this.InitializeComponent(); this.SizeChanged += (s, e) => { var state = "VisualState000min"; if (e.NewSize.Width > 500) state = "VisualState500min"; else if (e.NewSize.Width > 800) state = "VisualState800min"; else if (e.NewSize.Width > 1000) state = "VisualState1000min"; VisualStateManager.GoToState(this, state, true); };}

Page 26: UWP Adaptive UI

Adaptive triggersCode-free state transitionTwo built-in triggersMinWindowHeight (Taller than this)MinWindowWidth (Wider than this)

<VisualState x:Name="VisualState500min"> <VisualState.StateTriggers> <AdaptiveTrigger MinWindowWidth="501" /> </VisualState.StateTriggers></VisualState>

Page 27: UWP Adaptive UI

Adaptive triggers are a zero-code solution

Page 28: UWP Adaptive UI

Visual state settersSetting a simple, scalar valueGreat when you think of ENUM values like Visibility, Stretch, etc

Does not invoke a storyboardDoes not require ObjectAnimationUsingKeyFrames

<VisualState.Setters> <Setter Target="MyText01.FontSize" Value="24" /> <Setter Target="MyImage.Stretch" Value="UniformToFill" /> <Setter Target="MyImage.Height" Value="150" /></VisualState.Setters>

Page 29: UWP Adaptive UI

XAML's RelativePanel controlA child or two act as a anchor elementsThey are relative to the panel

Other children are relative to the anchorsRelativePanel.Above = "ElementName"RelativePanel.RightOf = "ElementName"RelativePanel.Below = "ElementName"RelativePanel.LeftOf = "ElementName"

RelativePanel simplifies adaptive UIA simple Visual State setter can rearrange the UIOne element can move a family of related elements

Page 30: UWP Adaptive UI

Demo: SplitView

Page 31: UWP Adaptive UI

Demo: Adaptive Triggers

Page 32: UWP Adaptive UI

Demo: Hide Content

Page 33: UWP Adaptive UI

Demo: SplitView with Adaptive Triggers

Page 34: UWP Adaptive UI

Demo: RelativePanel with Adaptive Triggers

Page 35: UWP Adaptive UI

Developers have many toolsto build an adaptive UI

Page 36: UWP Adaptive UI

ResourcesUWP Adaptive UI Demos - http://bitly.com/uwpuidemosUWP Adaptive UI Mail Client - http://bit.ly/uwpuiemailUWP UI Design - https://msdn.microsoft.com/en-us/magazine/mt590974.aspxChannel 9 Video - https://channel9.msdn.com/Series/A-Developers-Guide-to-Windows-10/07UWP Design Basics - https://dev.windows.com/en-us/design/design-basics

Page 37: UWP Adaptive UI

ResourcesSlides - http://www.slideshare.net/JamesQuick/uwp-adaptive-ui

Page 38: UWP Adaptive UI

ReviewThe Microsoft design languageHow Windows makes design easierWhat am I designing?Adaptive UI Techniques Adaptive UI Tooling

Page 39: UWP Adaptive UI

© 2015 Microsoft Corporation. All rights reserved.