62
What’s New in Silverlight 5 Mohammad Elsheimy http://JustLikeAMagic.com http://WithDotNet.net http://twitter.com/Elsheimy

What's New in Silverlight 5

Embed Size (px)

Citation preview

Page 1: What's New in Silverlight 5

What’s New in Silverlight 5

Mohammad Elsheimyhttp://JustLikeAMagic.com

http://WithDotNet.nethttp://twitter.com/Elsheimy

Page 2: What's New in Silverlight 5

Outline

Silverlight 5

XAML Changes

Control and Text Improvements

Graphics and Media Changes

Elevated-Trust Changes

Other Improvements

Get Started

Page 3: What's New in Silverlight 5

Silverlight 5

Currently in Beta version Has bugs, not yet feature-complete

Some features aren’t available in the Beta

No go-live license

First announced in PDC 2010

Beta released at MIX11

Final release soon this year

Page 4: What's New in Silverlight 5

Goals

Improving performance

Getting closer to WPF

Enabling line-of-business scenarios

Better development experience

Page 5: What's New in Silverlight 5

XAML CHANGES

Cairo

at N

ight

, Egy

pt

Page 6: What's New in Silverlight 5

XAML Changes

Implicit Data Templates

Ancestor RelativeSource

Binding in Styles

Markup Extensions

XAML Debugging

Layout Transitions

Page 7: What's New in Silverlight 5

Implicit Data Templates

Associated to a data type instead of a specific control

Applies to any control that… trying to display the data type specified

have a templatable content

defined in the scope of the template

Define outside the control (e.g. as a resource) Use DataType to specify the data type

Use binding to communicate with data

Typically used with collection controls (e.g. ListBox, ComboBox, etc.)

Page 8: What's New in Silverlight 5

DEMO: IMPLICIT DATA TEMPLATES

Page 9: What's New in Silverlight 5

Ancestor RelativeSource

Allows binding to a property on a parent control

Binding Outside the box

Implements the WPF feature

Use Binding.RelativeSource to specify the source in the tree Use AncestorType to specify parent type

Use AncestorLevel to specify its level in the tree

<TextBlock Text="{Binding Tag, RelativeSource={RelativeSource AncestorType=Grid, AncestorLevel=2}}"/>

Page 10: What's New in Silverlight 5

DEMO: ANCESTOR RELATIVESOURCE

Page 11: What's New in Silverlight 5

Binding in Styles

Allows changing styles during runtime

Implements the WPF feature

Binding is supported directly in style setters Use the standard binding syntax

All binding features supported (e.g. converters, formatters, etc.)

<Setter Property="Foreground" Value="{StaticResource theBrush}" />

Page 12: What's New in Silverlight 5

DEMO: BINDING IN STYLES

Page 13: What's New in Silverlight 5

Markup Extensions

Create your own markup extensions

Allows you to run custom code at XAML parsing time

Examples of markup extensions: {Binding}, {RelativeSource}, etc.

Much simpler than attached properties

More concise syntax

<TextBlock Text="{my:SumExtension FirstNumber=1, SecondNumber=2}" />

Page 14: What's New in Silverlight 5

Markup Extensions

Implement IMarkupExtension<T> (System.XAML) Where T is the type of the data that you wish to return (must be reference type)

Provide properties for parameters

Implement ProvideValue() to return the value

public class SumExtension : IMarkupExtension<object>{ public int FirstNumber { get; set; } public int SecondNumber { get; set; }

public object ProvideValue(IServiceProvider serviceProvider) { return FirstNumber + SecondNumber; }}

Page 15: What's New in Silverlight 5

DEMO: MARKUP EXTENSIONS

Page 16: What's New in Silverlight 5

XAML Debugging

Allows breakpoints in bindings Works by placing a breakpoint inside the binding in XAML

Stops on Push and Pull to the control

Use VS debugging tools to get binding details

Breakpoint condition and filters can be set

Past approaches: Hunt through the output window for any binding failure information

Create a debug-only value converter, assign it to all bindings, and put the breakpoint

inside it

Page 17: What's New in Silverlight 5

DEMO: XAML DEBUGGING

Page 18: What's New in Silverlight 5

Layout Transitions

Create a really rich experience without storyboards or animations just

with a few lines of XAML

Not in Beta

<VisualStateManager.LoadTransition> <LoadTransition StartXOffset="300“ GeneratedDuration="0:0:1.0" StartOpacity="0.2"> <LoadTransition.GeneratedEasingFunction> <CircleEase/> </LoadTransition.GeneratedEasingFunction> </LoadTransition></VisualStateManager.LoadTransition>

Page 19: What's New in Silverlight 5

CONTROL AND TEXT IMPROVEMENTS

View

from

Cai

ro to

wer

, Cai

ro, E

gypt

Page 20: What's New in Silverlight 5

Control Improvements

Text Tracking and Leading Control

Text Overflow

Multi-Click Support

Type-Ahead Text Searching

Default Filename in SaveFileDialog

DataContextChanged Event Not in Beta

Page 21: What's New in Silverlight 5

Text Tracking and Leading

Precisely set how far apart each character is (i.e. character spacing)

Precisely set the height for each line of the content

Available on text controls: TextBlock, TextBox, and RichTextBox

Use CharacterSpacing property to specify distance between characters Measured in 1000th of the font size (e.g. font size = 20px, CharacterSpacing = 500, then

20 * 500 / 1000 = 10px between each character)

Use LineHeight to specify each line’s height in pixels

Page 22: What's New in Silverlight 5

Line Stacking

Can be set using LineStackingStrategy

Specifies how each line’s box is determined

Page 23: What's New in Silverlight 5

DEMO: TEXT TRACKING AND LEADING

Page 24: What's New in Silverlight 5

Text Overflow

Allows for multi-column and free-form text layouts

RichTextBox is required as the master element

Can link one RichTextBoxOverflow to the RichTextBox to capture extra

text which doesn't fit Can continue the chain (i.e. linking another RichTextBoxOverflow to the previous one

and so on)

Use OverflowContentTarget property to specify the next target

<RichTextBox OverflowContentTarget="{Binding ElementName=theOverflow}"/><RichTextBoxOverflow x:Name="theOverflow" />

Page 25: What's New in Silverlight 5

Multi-Column Text

RichTextBox RichTextBoxOverflow RichTextBoxOverflow

Page 26: What's New in Silverlight 5

Free-Form Text

RichTextBox RichTextBoxOverflow

RichTextBoxOverflow

RichTextBoxOverflow

RichTextBoxOverflow

Page 27: What's New in Silverlight 5

DEMO: TEXT OVERFLOW

Page 28: What's New in Silverlight 5

Multi-Click Support

Allows you to capture n-clicks

Usually used to capture double-clicks (most useful) and triple-clicks

Added ClickCount property to MouseButtonEventArgs

Only valid on MouseLeftButtonDown and MouseRightButtonDown

Page 29: What's New in Silverlight 5

DEMO: MULTI-CLICK SUPPORT

Page 30: What's New in Silverlight 5

Type-Ahead Text Searching

Allows you to search for items by typing using keyboard

Works on collection controls (e.g. ComboBox, ListBox, etc.)

Works with implicit data templates

Should specify text to search within using DisplayMemberPath DisplayMemberPath is incompatible with explicit data templates

Page 31: What's New in Silverlight 5

DEMO: TYPE-AHEAD TEXT SEARCHING

Page 32: What's New in Silverlight 5

Text Improvements

Better text rendering

Improved performance of text layout

Text clarity is improved with Pixel Snapping

OpenType support has been enhanced

Page 33: What's New in Silverlight 5

GRAPHICS AND MEDIA CHANGES

Nile

Riv

er, C

airo

, Egy

pt

Page 34: What's New in Silverlight 5

Graphics Stack Changes

Improved Performance and Rendering

Hardware Acceleration More GPU support

New 3D API

Vector Printing Not in Beta

Print Preview Not in Beta

Page 35: What's New in Silverlight 5

Improved Performance

Uses Windows Phone 7 composition model Rendering happens on a separated, dedicated thread

Helps with immediate-mode rendering on the GPU

Added support for independent animations

Reduces flickers and “glitchy” animations happen when UI thread was interrupted

Page 36: What's New in Silverlight 5

3D API

XNA-based 3D stack Not game-loop based

Low-level access to GPU, vertex shaders, and 3D primitives

Can be used for immediate-mode 2D API

New DrawingSurface control to draw within Can do GraphicsDevice-based drawing

Silverlight Control now supports Draw event for custom drawing

Low-level support

Community will likely wrap to simplify use

Page 37: What's New in Silverlight 5

DEMO: 3D API

Page 38: What's New in Silverlight 5

Media Changes

Better Battery Management No screensaver in full-screen mode

Remote Control Support Not available in Beta

Hardware decoding; more GPU support H.264 media is now hardware decoded (not in Beta)

In Beta, no DRM or Mac support

1080p Support Combined with GPU, can watch 1080p on a Netbook/Tablet

Page 39: What's New in Silverlight 5

Media Changes

Speed Control; Trick Play

Low-latency sounds

IIS Media Services 4 Shipped, now supports Windows Azure

Page 40: What's New in Silverlight 5

Speed Control; Trick Play

Allows you to control play speed in MediaElement

Can slow-down or speed-up media

Can play media forward or backward

Use PlaybackRate to specify play speed (-8, -4, -2, …, 0.5, 1.2, 1.4, 2, 4, 8)

Limitations: No sound; pitch correction not available in Beta

Must set in code, if set in XAML will reset at application start

Page 41: What's New in Silverlight 5

DEMO: SPEED CONTROL; TRICK PLAY

Page 42: What's New in Silverlight 5

Low-Latency Sounds

Support for low-latency sounds Raw sounds data (e.g. wave files)

Uses the XNA approach

Can control volume, pitch, and stereo space

Use SoundEffect to load wave files and sound data

Use SoundEffectInstance to play multiple instances of the same audio

Limitations: Same limitations as XNA: 8 or 16bit PCM, mono or stereo, 22.5, 44.1, or 48khz

Page 43: What's New in Silverlight 5

DEMO: LOW-LATENCY SOUNDS

Page 44: What's New in Silverlight 5

ELEVATED-TRUST CHANGES

Nile

Riv

er, C

airo

, Egy

pt

Page 45: What's New in Silverlight 5

Elevated Trust

In-Browser Elevated-Trust Applications

Unrestricted File System Access

Multiple Window Support

Automation and P/Invoke Support Not in Beta

Page 46: What's New in Silverlight 5

In-Browser Elevated-Trust

Allows running elevated-trust applications in browser No longer need OOB to get elevated-trust features

Keyboard support in full-screen mode, enables for richer kiosk and media viewing apps

All elevated-trust features are available

Must be enabled by Client Access Policy file or Windows Registry Restricted to a private network or a single machine

XAP must be signed with a trusted certificate Certificate must be present in Trusted Publisher Certificate store

For development, “localhost” must be whitelisted

Windows only for Beta

Page 47: What's New in Silverlight 5

Client Access Policy Approach

Enable by setting ElevatedPermissions attribute in SecuritySettings

element to Required

<Deployment.OutOfBrowserSettings> ... <OutOfBrowserSettings.SecuritySettings> <SecuritySettings ElevatedPermissions="Required" /> <OutOfBrowserSettings.SecuritySettings> ...</Deployment.OutOfBrowserSettings>

Page 48: What's New in Silverlight 5

Windows Registry Approach

Enable by hooking into registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Silverlight

Set AllowElevatedTrustAppsInBrowser (DWORD) to 0x00000001 to

enable running elevated-trust applications in browser

Use AllowInstallOfElevatedTrustApps to enable/disable installation of

elevated-trust applications completely (in-browser or out-of-browser)

Use AllowLaunchOfElevatedTrustApps to enable/disable elevated-trust

applications completely (in-browser or out-of-browser)

Page 49: What's New in Silverlight 5

DEMO: IN-BROWSER ELEVATED-TRUST

Page 50: What's New in Silverlight 5

Multiple Window Support

Allows you to create multiple windows in OOB applications Works on Windows and Mac

Can have custom chrome

Requires elevated trust

Window class is now instantiable Must set location and size

Use Visibility to show the new window

Page 51: What's New in Silverlight 5

DEMO: MULTIPLE-WINDOW SUPPORT

Page 52: What's New in Silverlight 5

File System Access

Unrestricted file system access for elevated-trust applications Same rights as the user

Access to complete information

Page 53: What's New in Silverlight 5

DEMO: FILE SYSTEM ACCESS

Page 54: What's New in Silverlight 5

OTHER IMPROVEMENTS

Libr

ary

of A

lexa

ndria

, Ale

xand

ria, E

gypt

Page 55: What's New in Silverlight 5

Performance Improvements

Improved startup performance Multi-core background JIT support

Improved XAML parsing time Specially for UserControls and ResourceDictionaries

64-bit support Not in Beta

Network latency optimizations

90% performance improvements in ClientHttpWebRequest scenarios

Hardware accelerated rendering in Internet Explorer 9 windowless mode Using the new SurfacePresenter API (not in Beta)

Page 56: What's New in Silverlight 5

Other Improvements

Enabled WS-Trust support in WCF

Windows Azure support

In-browser HTML support

Automated UI testing

Improved profiling support Memory

CPU

Thread contention

Many more fixes and improvements throughout the product

Page 57: What's New in Silverlight 5

GET STARTED

Nile

Riv

er, A

swan

, Egy

pt

Page 58: What's New in Silverlight 5

Getting Started

Install Visual Studio 2010 SP1

Visit http://silverlight.net Install the Silverlight 5 Beta Tools for Visual Studio 2010

Optionally, install the Expression Blend Preview for Silverlight 5 Beta

Make cool stuff!

Page 59: What's New in Silverlight 5

HAVE A QUESTION?

Page 60: What's New in Silverlight 5

EVALUATION

Page 61: What's New in Silverlight 5

CONTACT

Mohammad Elsheimy

http://JustLikeAMagic.comhttp://WithDotNet.net

http://twitter.com/elsheimyhttp://facebook.com/justlikeamagic

Page 62: What's New in Silverlight 5

THANK YOU!