What's New in Silverlight 5

Page 1

What’s New in Silverlight 5

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


What’s New In Silverlight 5 • • • • •

Data Binding Improvements Text Controls Media Trusted Applications

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Data binding improvements • • • • • •

Data binding debugging Ancestor RelativeSource binding Implicit data templates UpdateSourceTrigger=PropertyChanged Binding in style setters Custom markup extensions

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Data binding improvements • These updates are very welcome changes for developers using MVVM in their applications

Learn More @ http://www.learnnowonline.com Copyright Š by Application Developers Training Company


Model-View-ViewModel (MVVM) • • • • •

It’s a separation pattern, like MVC or MVP Improves structure / separation of concerns Enables better designer / developer workflow Enhances testability Made possible by the robust data binding capabilities of Silverlight and WPF

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


MVVM Structure View •XAML •Data bindings

View Model •Model of the View (or View of the Model) •Properties and commands

Model •Domain model / business logic •Services, persistence, everything else

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Connecting the pieces of MVVM • View -> ViewModel • ViewModel exposes properties and commands that

the view binds to • ViewModel implements INotifyPropertyChanged to relay change notifications to View • The View’s DataContext is bound to the ViewModel, making all of it’s properties and commands available to the entire View

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Connecting the pieces of MVVM • ViewModel -> View • ViewModel contains domain objects from the

Model and exposes relevant portions of it to the View • ViewModel calls services to fetch or save data to the Model

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Key elements of MVVM • INotifyPropertyChanged • PropertyChanged event

• ICommand • Execute • CanExecute • CanExecuteChanged event

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


MVVM Basics

DEMO Learn More @ http://www.learnnowonline.com Copyright Š by Application Developers Training Company


Data binding debugging • Allows breakpoints on data binding statements • Exposes information on the data binding source, errors, etc… • Makes troubleshooting data binding issues really easy!

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Data binding debugging

DEMO Learn More @ http://www.learnnowonline.com Copyright Š by Application Developers Training Company


Ancestor RelativeSource binding • New binding mode brought over from WPF • Allows a child element to bind to properties on its parent • Very useful within item templates in an items control

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Ancestor RelativeSource binding

DEMO Learn More @ http://www.learnnowonline.com Copyright Š by Application Developers Training Company


Implicit data templates • Another binding feature from WPF • Defines a template to be used whenever Silverlight tries to display a particular type • In Silverlight 4, we had to explicitly specify a template for our custom types • Very useful when binding to a list of different subclasses – not limited to a single item template now! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Implicit data templates

DEMO Learn More @ http://www.learnnowonline.com Copyright Š by Application Developers Training Company


New UpdateSourceTrigger • Adds “PropertyChanged” option to available UpdateSourceTriggers – also from WPF • When used, the source of the binding (on our ViewModel) is updated whenever the property on the View is changed

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


PropertyChanged UpdateSourceTrigger

DEMO Learn More @ http://www.learnnowonline.com Copyright Š by Application Developers Training Company


Custom markup extensions • Markup extensions are the parts of XAML that are surrounded by {curly braces} • Binding, StaticResource, DynamicResource, etc…

• They provide a value – one that is often not known until runtime • Silverlight 5 now allows us to create our own markup extensions

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Custom markup extensions

DEMO Learn More @ http://www.learnnowonline.com Copyright Š by Application Developers Training Company


Binding in Style Setters • Styles are useful and widely used to define a consistent look and feel to our applications • Until now, binding in the setters within styles were now allowed • Silverlight 5 allows us to create binding statements within stlyes

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Binding in style setters

DEMO Learn More @ http://www.learnnowonline.com Copyright Š by Application Developers Training Company


What’s New In Silverlight 5 • • • • •

Data Binding Improvements Text Controls Media Trusted Applications

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Text improvements • • • •

Character spacing and line height TextOptions – pixel snapping OpenType support Linked text blocks for multi-column and flowing text

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Character spacing and line height • “CharacterSpacing” and “LineHeight” properties • TextBox, TextBlock, RichTextBox, RichTextBlock

• CharacterSpacing calculated based formula: Spacing (in pixels) = (font size * Value) / 1000

• LineHeight is the spacing between lines, in pixels

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Linked text • RichTextBlocks can now specify a RichTextBlockOverflow element that text will flow to when full • RichTextBlockOverflow elements can specify additional overflow containers • Limited only to read-only RichTextBlocks

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Linked text, character spacing and line height

DEMO Learn More @ http://www.learnnowonline.com Copyright Š by Application Developers Training Company


TextOptions • TextFormattingMode • Ideal, Display (pixel snapping)

• TextHintingMode • Fixed, Animated

• TextRenderingMode • Auto, Aliased, Greyscale, ClearType

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


OpenType Support • • • • • •

Ligatures – glyphs with more than one letter Contextual Alternates Stylistic Sets Variants – superscript and subscript Fractions Much more in the Typography class!

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


TextOptions and OpenType

DEMO Learn More @ http://www.learnnowonline.com Copyright Š by Application Developers Training Company


What’s New In Silverlight 5 • • • • •

Data Binding Improvements Text Controls Media Trusted Applications

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


What’s New in Silverlight 5

Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company


Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details!

Learn More @ http://www.learnnowonline.com Copyright Š by Application Developers Training Company


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.