Top Banner
Thinking about the future with Windows 8 SILVERLIGHTSHOW.NET WEBINARS SERIES GILL CLEEREN, 29 th November 2011 www.snowball.be - [email protected] - @gillcleeren
81
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: An introduction to Windows 8 development.pptx

Thinking about the future with Windows 8SILVERLIGHTSHOW.NET WEBINARS SERIESGILL CLEEREN, 29th November 2011www.snowball.be - [email protected] - @gillcleeren

Page 2: An introduction to Windows 8 development.pptx

About myself...• Gill Cleeren• .NET Architect @Ordina (www.ordina.be) • Microsoft Regional Director• Silverlight MVP• Speaker (TechDays, TechEd, DevReach, DevDays, NDC Norway,

Telerik Usergroup tour Sweden, UK and Scotland...)• Visug user group lead (www.visug.be)• Author (Silverlight 4 Data and services cookbook, 15 MVPs book),

SilverlightShow articles– And finishing Silverlight 5 cookbook now!

• Blog: www.snowball.be• Email: [email protected] • Twitter: @gillcleeren

Page 3: An introduction to Windows 8 development.pptx

Warning!

I have a cold...

Luckily for you, this is not contagious over a webinar

Page 4: An introduction to Windows 8 development.pptx

Some practical stuff

• Ask questions through Q&A window– We’ll answer them after the session or by personal

mail• A link to the video recording will be sent to you

Page 5: An introduction to Windows 8 development.pptx

XAML: a 4-day Training in London, UK

• Master XAML, Silverlight, WPF, WP7 and Windows 8!

• February 20th 24th, London, UK

• Organized by CompletITand Ordina

• More info via [email protected]

www.silverlightshow.net/trainings/training_london0212.aspxBus to training

Page 6: An introduction to Windows 8 development.pptx

Agenda

• What did we see at BUILD?– Hello Windows 8

• What is WinRT?– How do we write Metro apps

• Leveraging tomorrow what we know today– C# and .NET in Metro-style apps– XAML for Metro-style apps

Page 7: An introduction to Windows 8 development.pptx

CHRISTMAS EVE IN SEPTEMBERWhat did we get at BUILD?

Page 8: An introduction to Windows 8 development.pptx

Before BUILD...

We had...– Desktop apps with .NET• WPF

– Web apps with .NET• ASP.NET/ASP.NET MVC• Silverlight

Page 9: An introduction to Windows 8 development.pptx

At BUILD, we got...

• Steven Sinofsky annoucing hardware– Including Windows 8 running on ARM

Page 10: An introduction to Windows 8 development.pptx

At BUILD, some got...

It’s possible to buy this device now with Windows 7, costs around $1200

Donations welcome on paypal: [email protected] ;-)

Page 11: An introduction to Windows 8 development.pptx

At BUILD, we got...

• Windows 8– And everyone can get it from dev.windows.com

Page 12: An introduction to Windows 8 development.pptx

At BUILD, we also got...

• “Metro apps”• Windows Runtime (aka WinRT)• Visual Studio Express 2011 – Only for building Metro-style apps

• .NET 4.5• Visual Studio 11 Developer Preview– That’s “The Big One”

• And more sessions than you can shake a stick at!

Page 13: An introduction to Windows 8 development.pptx

DEMO

Hello future aka “The demo of Windows 8”

Page 14: An introduction to Windows 8 development.pptx

WINDOWS RUNTIME (WINRT)Opening Windows to managed developers

Page 15: An introduction to Windows 8 development.pptx

The Windows Runtime is the solid, efficient foundation

for building great Metro style apps,giving you access to Windows the language

of your choice

FACT

Page 16: An introduction to Windows 8 development.pptx

Windows 8

Windows Kernel Services

JavaScript(Chakra)C/C++ C#, VB

Metro style Apps

Communication & Data

Application Model

Devices & Printing

Windows Runtime APIsGraphics &

Media

XAML HTML / CSS

HTMLJavaScript

CC++

C#VB

Desktop Apps

Win32 .NET SL

Internet Explorer

Page 17: An introduction to Windows 8 development.pptx

Devices

SensorsGeolocation Portable NFC

Communications & Data

Contracts

XML

Web

SMSNetworking

Notifications

Local & Cloud Storage

Streams

Background Transfer

User Interface

HTML5/CSS XAML DirectX Controls

Input Accessibility Printing

Data Binding

TilesSVG

Metro style application APIs

FundamentalsApplication

ServicesAuthentication Cryptography Globalization

Memory ManagementThreading/Timers

MediaVisual Effects

Playback PlayToCapture

Page 18: An introduction to Windows 8 development.pptx

Windows Runtime Architecture

Windows Metadata & Namespace

Language Projection

Windows Core

Windows Runtime Core

XAML Storage …Network

UI Pickers MediaControls

Metro style app

Runtime Broker

Language Support (CLR, WinJS, CRT)

Web Host (HTML, CSS, JavaScript)

Page 19: An introduction to Windows 8 development.pptx

Why WinRT was born...

• We had Win32 APIs for a long time• It wasn’t a good idea to just give these to

developers to build Windows 8 apps– Developers want IntelliSense, debugging...– Developers want to use the language of their

choice Microsoft doesn’t force the developer in using a certain technology or language

Page 20: An introduction to Windows 8 development.pptx

So WinRT is...

• A huge improvements in the developer experience for the Windows developer– IntelliSense, debugging...

• Fast and fluid (aka responsive)– Async is the new buzzword– No synchronous IO calls

• Natural and familiar– New APIs– Language of choice

• Based on apps– Apps can “communicate” through defined app-to-app contracts– Apps should keep running no matter what the OS version

Page 21: An introduction to Windows 8 development.pptx

DEMOHello World in WinRT in Visual Studio 2011 Express using HTML

Page 22: An introduction to Windows 8 development.pptx

Windows Runtime Architecture

Windows Metadata & Namespace

Language Projection

Windows Core

Windows Runtime Core

XAML Storage …Network

UI Pickers MediaControls

Metro style app

Runtime Broker

Language Support (CLR, WinJS, CRT)

Web Host (HTML, CSS, JavaScript)

Page 23: An introduction to Windows 8 development.pptx

All new: Windows Metadata

• We all know assembly metadata– ILDASM can open it for you– Use extensively in CLR to know what an assembly

can do for you• Windows Metadata is the same concept but

native

Page 24: An introduction to Windows 8 development.pptx

Windows Metadata

• Concise, complete description of the Windows Runtime

• Generated natively from C++ or C#/VB Compiler• Efficient binary format derived CLI Metadata– Same structures, different meanings

• Rich enough to allow multi-language projection generation

• Full IntelliSense on statically known information– Same experience for managed developers as we have

today

Page 25: An introduction to Windows 8 development.pptx

The Windows Namespace

• Windows.* Runtime objects are in a simple, unified, hierarchical namespace

• Great IntelliSense and browsing in Visual Studio

• One clear type for each function

Page 26: An introduction to Windows 8 development.pptx

* Top level namespaces only

The WinRT API

• Windows.ApplicationModel• Windows.Data• Windows.Devices• Windows.Foundation• Windows.Globalization• Windows.Graphics• Windows.Management• Windows.Media • Windows.Networking• Windows.Security

• Windows.Storage • Windows.System• Windows.UI[.Xaml]• Windows.Web

Page 27: An introduction to Windows 8 development.pptx

DEMOSame app but now using C#

Page 28: An introduction to Windows 8 development.pptx

Windows Runtime Architecture

Windows Metadata & Namespace

Language Projection

Windows Core

Windows Runtime Core

XAML Storage …Network

UI Pickers MediaControls

Metro style app

Runtime Broker

Language Support (CLR, WinJS, CRT)

Web Host (HTML, CSS, JavaScript)

Page 29: An introduction to Windows 8 development.pptx

Language Projections

• C++• .NET• JavaScript

Page 30: An introduction to Windows 8 development.pptx

Windows Tailored Profile

• System.Collections• System.ComponentModel• System.Diagnostics• System.Dynamic• System.Globalization• System.IO• System.Linq• System.Net• System.Numerics• System.Reflection

• System.Resources• System.Runtime• System.Security• System.ServiceModel• System.Text• System.Threading• System.Xml

Page 31: An introduction to Windows 8 development.pptx

What’s missing in the Windows Tailored Profile

• Enterprise Development– ASP.NET– Console– DirectoryServices– Windows Forms– WPF– WF

• Dangerous, obsolete, legacy• Removed duplicates• Removed badly designed APIs

Page 32: An introduction to Windows 8 development.pptx

.NET for Metro style apps

.NET for Metro style apps

.NET 4.5 Windows Phone 7

# of assemblies 15* 120 22

# of namespaces 60 400 88

# of types ~1K ~14K ~2K

# of members ~10K ~110K ~14K

* Refers to implementation assemblies, not reference assemblies.

Page 33: An introduction to Windows 8 development.pptx

LEVERAGING TOMORROW WHAT WE KNOW TODAY

C# for Metro style apps

Page 34: An introduction to Windows 8 development.pptx

Windows has always provided compelling capabilities for developers to build upon

Windows has not always made it straightforward for you to use these

capabilities from C# or VB

FACT

Page 35: An introduction to Windows 8 development.pptx

[DllImport("avicap32.dll", EntryPoint="capCreateCaptureWindow")]static extern int capCreateCaptureWindow( string lpszWindowName, int dwStyle, int X, int Y, int nWidth, int nHeight, int hwndParent, int nID);

[DllImport("avicap32.dll")] static extern bool capGetDriverDescription( int wDriverIndex, [MarshalAs(UnmanagedType.LPTStr)] ref string lpszName, int cbName, [MarshalAs(UnmanagedType.LPTStr)] ref string lpszVer, int cbVer);

// more and more of the same

A small, easy sample of Win32 code

Page 36: An introduction to Windows 8 development.pptx

Traditional Windows API

Your Managed

Code

Manually Generated

Interop Code

There’s a hole somewhere...

Page 37: An introduction to Windows 8 development.pptx

On Windows 8, this will now be…

using Windows.Media.Capture;

var ui = new CameraCaptureUI();ui.PhotoSettings.CroppedAspectRatio = new Size(4,3);

var file = await ui.CaptureFileAsync(CameraCaptureUIMode.Photo);

if (file != null) { var bitmap = new BitmapImage() ; bitmap.SetSource(await file.OpenAsync(FileAccessMode.Read)); Photo.Source = bitmap;}

Page 38: An introduction to Windows 8 development.pptx

Traditional Windows API

Your Managed

Code

Windows Runtime

The hole is gone

Page 39: An introduction to Windows 8 development.pptx

We already have the skills to build Metro style applications using C#

(and VB as well)

FACT

Page 40: An introduction to Windows 8 development.pptx

C# and Visual Basic influencedthe Windows Runtime

FACT

Page 41: An introduction to Windows 8 development.pptx

Windows Runtime is designed to be used from object-oriented languages

like C# and Visual Basic

FACT

Page 42: An introduction to Windows 8 development.pptx

Windows Runtime metadata files use an updated version of .NET’s metadata format

FACT

Page 43: An introduction to Windows 8 development.pptx

DEMOUsing ILDASM for Windows Metadata files

Page 44: An introduction to Windows 8 development.pptx

Windows Runtime includes a XAML based framework for Metro style apps

(we’ll see that in more detail further)

FACT

Page 45: An introduction to Windows 8 development.pptx

Many of the Windows Runtime design guidelines

came from the .NET design guidelines

FACT

Page 46: An introduction to Windows 8 development.pptx

Windows Runtime was expressly designed to work well with C# and Visual Basic

FACT

Page 47: An introduction to Windows 8 development.pptx

Using the Windows Runtime feels natural and familiar

from C# and Visual Basic

FACT

Page 48: An introduction to Windows 8 development.pptx

DEMOUsing the Windows Runtime from C#

Page 49: An introduction to Windows 8 development.pptx

Most WinRT types map directly to C#/VB

var ui = new CameraCaptureUI();ui.PhotoSettings.CroppedAspectRatio = new Size(4, 3);

var file = await ui.CaptureFileAsync(CameraCaptureUIMode.Photo);

if (file != null) { var bitmap = new BitmapImage() ; bitmap.SetSource(await file.OpenAsync(FileAccessMode.Read)); Photo.Source = bitmap;}

Page 50: An introduction to Windows 8 development.pptx

Almost everything maps directly between the Windows Runtime and .NET

• Primitives(strings, numbers, etc)

• Interfaces• Enums• Structs• Delegates

• Delegates• Constructors• Static Members• Properties• Events• Methods

Page 51: An introduction to Windows 8 development.pptx

Most differences between Windows Runtime and

.NET are hidden from the managed developer

FACT

Page 52: An introduction to Windows 8 development.pptx

Exceptions from HRESULTs

try

{ var ui = new CameraCaptureUI(); ui.PhotoSettings.CroppedAspectRatio = new Size(16, 9);}catch (Exception e){ //Exception handling code}

ComException

Page 53: An introduction to Windows 8 development.pptx

Accessing a WinRT Collection from C#

var picker = new FileOpenPicker();picker.FileTypeFilter.Add("*");var files = await picker.PickMultipleFilesAsync();foreach (StorageFile file in files){ lbFiles.Items.Add(file.FileName);}

System.Collections.Generic.IReadOnlyList <Windows.Storage.StorageFile>

Windows.Foundation.Collections.IVectorView <Windows.Storage.StorageFile>

Page 54: An introduction to Windows 8 development.pptx

LEVERAGING TOMORROW WHAT WE KNOW TODAY

XAML for Metro style apps

Page 55: An introduction to Windows 8 development.pptx

Focusing now on…

Windows Kernel Services

JavaScript(Chakra)

C/C++ C#, VB

Metro style Apps

Communication & Data

Application Model

Devices & Printing

Windows Runtime APIsGraphics &

Media

XAML HTML / CSS

HTMLJavaScript

CC++

C#VB

Desktop Apps

Win32 .NET SL

Internet Explorer

Page 56: An introduction to Windows 8 development.pptx

Moving from current XAML to WinRT

• It’s all XAML– What you know, remains valid

• You as a Silverlight/WPF/WP7 developer can now add Windows 8 developer to your business card!

• If you know C++, you can now integrate that with XAML as well

Page 57: An introduction to Windows 8 development.pptx

Concepts that carry forward

• Same control model as we have today in Silverlight and WPF– Many controls can just be copied to WinRT– Same thing, but now native

• Concepts:– Data binding, change notification– Styling– Animations– Visual State Manager– Already seen: C#, VB.NET and C++

• Some things may not be natively supported though• XAML is now exposed as a WinRT API

– No wrappers!

Page 58: An introduction to Windows 8 development.pptx

DEMOSilverlight app to Metro app

Page 59: An introduction to Windows 8 development.pptx

What do you get as extra?

• WinRT (duh)– APIs are aimed at building Metro style apps only

• Metro style, look and feel• Touch is now fully supported, next to mouse input– Unified under “PointerXXX”

• Metro style controls • New base namespace – Windows.UI.Xaml

• Windows Store

Page 60: An introduction to Windows 8 development.pptx

Input is now touch-driven

• Things will still work with a mouse though

Page 61: An introduction to Windows 8 development.pptx

DEMOMetro-style UI

Page 62: An introduction to Windows 8 development.pptx

Running an application

Tile -> Splash Screen -> App (App UI)

XAML UI Starts Here

Page 63: An introduction to Windows 8 development.pptx

Controls for Metro-style apps

List Box

Hyperlink

CheckboxProgress Bar

Text Box

Password

Progress Ring

Tooltip

Grid ViewButton

Flip View

Combo Box

Scroll Bar

Context Menu

Slider

Toggle Switch

Semantic Zoom

Panning Indicator

Navigation

List View

Web View

Radio Button

Clear Button

Reveal Button

Spell Checking

Page 64: An introduction to Windows 8 development.pptx

ListView and GridView are the new kids

• Windows 8 “list controls”• Optimized for touch input• Support Windows 8 selection models• UI and Data Virtualization• Built in grouping

Page 65: An introduction to Windows 8 development.pptx

DEMOUsing a GridView

Page 66: An introduction to Windows 8 development.pptx

And more new controls…

• MediaPlayer• ToggleSwitch• ProgressRing• FlipView• JumpViewer– Semantic Zoom Control– Supports 2 Levels

Page 67: An introduction to Windows 8 development.pptx

DEMOUsing a FlipView

Page 68: An introduction to Windows 8 development.pptx

The ApplicationBar, another new control

• Used to place commands– “Inherited” from Windows Phone 7

• Persistent, light dismiss or time dismiss• Swipe in from top/bottom to display

Page 69: An introduction to Windows 8 development.pptx

DEMOUsing the ApplicationBar

Page 70: An introduction to Windows 8 development.pptx

SOME MORE CONCEPTS

Page 71: An introduction to Windows 8 development.pptx

Screen resolution and orientation

• Screen resolution:– Current Resolution:

• Window.Current.Bounds

– Event:• Window.Current.SizeChanged

• Orientation– Current (Namespace: Windows.Graphics.Display)

• DisplayProperties.CurrentOrientation

– Event:• DisplayProperties.OrientationChanged

Page 72: An introduction to Windows 8 development.pptx

Detecting Layout

• An application should support more than just the default view

• Can detect when the view changes to react by showing another view– ApplicationLayout.GetForCurrentView().LayoutChanged

Snapped Filled Full Screen

Page 73: An introduction to Windows 8 development.pptx

DEMOUsing Snapped View

Page 74: An introduction to Windows 8 development.pptx

Integrating with Windows

• An application can integrated withWindows and other applicationsthrough the “charms”– Search– Share– Devices– Settings– Picker

• A charm is like a contract, a way of letting applications talk without knowing each other

Page 75: An introduction to Windows 8 development.pptx

The “share” charm

• A source app will share something• Target app will get the shared data• Between the two, some common formats are

provided for data interchange• Should your app share?– Yes, most apps that create something should be

sharing data• Should an app be a target?– If your app does things like publishing, storing or

transforming data, then yes.– IM, translator, uploader...

Page 76: An introduction to Windows 8 development.pptx

Specifying capabilities

• Just like Windows Phone 7, an application needs to specify what it needs in the Application Manifest– Declare the intent towards system resources

Page 77: An introduction to Windows 8 development.pptx

The lifetime of a Metro app

• Only the foreground app is Active• All other background apps are Suspended– They get a notification about it

• While suspended, apps may be Terminated– They won’t be notified about this

Page 78: An introduction to Windows 8 development.pptx

Summary

• A new world is opening up• As a developer now– We need to learn some new things– Most of our current knowledge is carried over– Our investments are safe (Silverlight, HTML, C++...)

Page 79: An introduction to Windows 8 development.pptx

Q&A

Page 80: An introduction to Windows 8 development.pptx

THANKS!

Page 81: An introduction to Windows 8 development.pptx

Thinking about the future with Windows 8SILVERLIGHTSHOW.NET WEBINARS SERIESGILL CLEEREN, 29th November 2011www.snowball.be - [email protected] - @gillcleeren