Upload
mohammad-elsheimy
View
1.780
Download
0
Embed Size (px)
Citation preview
What’s New in Silverlight 5
Mohammad Elsheimyhttp://JustLikeAMagic.com
http://WithDotNet.nethttp://twitter.com/Elsheimy
Outline
Silverlight 5
XAML Changes
Control and Text Improvements
Graphics and Media Changes
Elevated-Trust Changes
Other Improvements
Get Started
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
Goals
Improving performance
Getting closer to WPF
Enabling line-of-business scenarios
Better development experience
XAML CHANGES
Cairo
at N
ight
, Egy
pt
XAML Changes
Implicit Data Templates
Ancestor RelativeSource
Binding in Styles
Markup Extensions
XAML Debugging
Layout Transitions
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.)
DEMO: IMPLICIT DATA TEMPLATES
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}}"/>
DEMO: ANCESTOR RELATIVESOURCE
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}" />
DEMO: BINDING IN STYLES
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}" />
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; }}
DEMO: MARKUP EXTENSIONS
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
DEMO: XAML DEBUGGING
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>
CONTROL AND TEXT IMPROVEMENTS
View
from
Cai
ro to
wer
, Cai
ro, E
gypt
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
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
Line Stacking
Can be set using LineStackingStrategy
Specifies how each line’s box is determined
DEMO: TEXT TRACKING AND LEADING
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" />
Multi-Column Text
RichTextBox RichTextBoxOverflow RichTextBoxOverflow
Free-Form Text
RichTextBox RichTextBoxOverflow
RichTextBoxOverflow
RichTextBoxOverflow
RichTextBoxOverflow
DEMO: TEXT OVERFLOW
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
DEMO: MULTI-CLICK SUPPORT
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
DEMO: TYPE-AHEAD TEXT SEARCHING
Text Improvements
Better text rendering
Improved performance of text layout
Text clarity is improved with Pixel Snapping
OpenType support has been enhanced
GRAPHICS AND MEDIA CHANGES
Nile
Riv
er, C
airo
, Egy
pt
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
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
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
DEMO: 3D API
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
Media Changes
Speed Control; Trick Play
Low-latency sounds
IIS Media Services 4 Shipped, now supports Windows Azure
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
DEMO: SPEED CONTROL; TRICK PLAY
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
DEMO: LOW-LATENCY SOUNDS
ELEVATED-TRUST CHANGES
Nile
Riv
er, C
airo
, Egy
pt
Elevated Trust
In-Browser Elevated-Trust Applications
Unrestricted File System Access
Multiple Window Support
Automation and P/Invoke Support Not in Beta
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
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>
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)
DEMO: IN-BROWSER ELEVATED-TRUST
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
DEMO: MULTIPLE-WINDOW SUPPORT
File System Access
Unrestricted file system access for elevated-trust applications Same rights as the user
Access to complete information
DEMO: FILE SYSTEM ACCESS
OTHER IMPROVEMENTS
Libr
ary
of A
lexa
ndria
, Ale
xand
ria, E
gypt
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)
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
GET STARTED
Nile
Riv
er, A
swan
, Egy
pt
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!
HAVE A QUESTION?
EVALUATION
CONTACT
Mohammad Elsheimy
http://JustLikeAMagic.comhttp://WithDotNet.net
http://twitter.com/elsheimyhttp://facebook.com/justlikeamagic
THANK YOU!