Wednesday, October 6, 2010

What's New in Silverlight 4

Silverlight 4 includes several new features that are based on customer suggestions. This topic introduces some of the new features and improvements in Silverlight 4. For more information, see New Silverlight 4 Features.
This topic contains the following sections.
• Controls
• Out-of-Browser
• Media
• Networking
• Printing
• User Interface
• XAML
• Data
• Application Model
• Core
• Silverlight Designer
• Windows Phone Platform Support
• Related Topics
Controls
________________________________________
RichTextBox Control
The RichTextBox control enables you to display, enter, and edit rich text. You can apply character or paragraph formatting to the text, display hyperlinks, and add inline images. For more information, see RichTextBox Overview.
Viewbox Control
The Viewbox control is a content decorator that takes one child element and stretches it or scales it to fit the size of the Viewbox. For more information, see Viewbox.
WebBrowser Control
The WebBrowser control provides a surface for displaying HTML content when the application runs outside the browser. For more information, see WebBrowser.
WebBrowserBrush Control
You can use the WebBrowserBrush control to display HTML content from a WebBrowser control. For example, you can use a WebBrowserBrush to paint the Fill of a shape such as a Rectangle or the geometry contents of a Path. For more information, see WebBrowserBrush.
Out-of-Browser
________________________________________
Out-of-Browser Support
Out-of-browser applications now support several features that are unavailable to browser-hosted applications, including the following:
• Window features including run-time resizing, always on top capability, and a Closing event that you can cancel.
• Support for offline digital rights management (DRM).
• HTML hosting with the WebBrowser control.
• Popup alerts with the NotificationWindow class.
• Support for elevated trust.
• Improved support for debugging out-of-browser applications.
For more information, see Out-of-Browser Support. Some of these features are also described in the following sections.
Trusted Applications
You can configure out-of-browser applications to require elevated trust. Trusted applications can bypass some of the restrictions of the Silverlight security sandbox and integrate with native functionality. For example, out-of-browser applications running in elevated trust can read and write files in user folders, and use full-screen mode without keyboard restrictions.
Additionally, trusted applications can access Window APIs that enable complete customization of the out-of-browser application window. For example, trusted applications can hide the window title bar and border and provide custom user-interface elements for moving, resizing, or closing the window.
Trusted applications display a security warning to users prior to installation. However, Silverlight supports application signing for trusted applications, and displays a more reassuring warning for applications with verified signatures.
For more information, see Trusted Applications and System.IO.
Late Binding
Silverlight now supports late binding in both Visual Basic and C#. Visual Basic supports late binding by default for variables of type Object. C# supports late binding for variables of type dynamic. This enables you to work more easily with objects retrieved from the HTML DOM or from Automation APIs.
To support late binding to HTML DOM elements, the ScriptObject class now implements the IDynamicMetaObjectProvider interface. To support late binding to Automation APIs, the AutomationFactory class and related classes have been added to the Silverlight framework.
For more information about Automation, see How to: Use Automation in Trusted Applications.
Media
________________________________________
Webcam and Microphone
You can now capture source input from the user's audio device or video device. The CaptureImageAsync method enables a simple screen capture scenario and the VideoBrush.SetSource method enables a simple video playback scenario. More advanced scenarios can access raw audio or video and process it into file formats. Webcam and microphone capture both use a sink metaphor for establishing a listener class, and obtaining a capture requires client user permission for capture device access. For more information, see CaptureSource, AudioSink, VideoSink, and Webcam and Device Overview.
DRM for Offline
There are a number of new features integrated into Silverlight DRM that can be used to implement offline scenarios including purchase and download, rentals, and subscriptions. For more information, see Digital Rights Management (DRM).
Networking
________________________________________
Multicast
The System.Net.Sockets namespace has added support for UDP multicast clients. This allows network clients to take advantage of multicast applications that more efficiently use network resources. For more information, see the Working with Multicast topic and the System.Net.Sockets.UdpAnySourceMulticastClient and System.Net.Sockets.UdpSingleSourceMulticastClient classes.
Socket Security Policy Retrieval Using HTTP
For a connection request using System.Net.Sockets, an application can choose to retrieve the socket policy file by using the HTTP protocol on TCP port 80 instead of the custom TCP protocol on port 943. This allows HTTP servers that are already running HTTP services to authorize socket connections from Silverlight applications without having to deploy a new TCP service on the server and open a port through a firewall for port 943. The socket policy file is retrieved via HTTP by using the resolved IP address as the host where the socket connection is targeted. This results in an authoritative machine-wide policy for the target necessary for machine resources, such as sockets. In contrast, the policy file for use by the WebClient and HTTP classes in the System.Net namespace is retrieved from the host domain that is targeted by the HTTP request. The HTTP protocol allows for isolation of resources on a per-domain basis through the Host header. For more information, see Network Security Access Restrictions in Silverlight.
Relaxed Security Policy for Trusted Applications
The System.Net.Sockets namespace includes support for relaxed security policy restrictions applied to out-of-browser trusted applications that communicate using System.Net.Sockets. For more information, see Network Security Access Restrictions in Silverlight and Trusted Applications.
Client HTTP Processing
There have been several feature additions when you opt in to client HTTP processing for your networking calls:
• Referer header is sent on all requests
• Basic and NTLM authentication support
• Caching support
• Ability to enable or disable stream buffering for read and write requests
• Concurrent connection limit is raised from 2 to 6
For more information about opting in to client HTTP processing, see How to: Specify Browser or Client HTTP Handling
Printing
________________________________________
You can now print the user interface of a Silverlight application by using the PrintDocument class. The PrintDocument enables you to show a print dialog box to the user and to print the application or a UIElement contained in the application. For more information, see Printing.
User Interface
________________________________________
Drag-and-Drop
Silverlight 4 introduces APIs to support drag-and-drop. You can select a file list from applications outside of the Silverlight content area, for example from My Documents in Microsoft Windows. You can then drag the selected file list into the Silverlight content area, handle drop events on a particular target element, and then process the file list by using FileInfo information including access to file content through streams. This is enabled by adding the Drop event and related events and properties to the base UIElement class. Support classes, such as DragEventArgs, are also included.
Clipboard Access
Silverlight 4 introduces APIs to support clipboard object access. You can get or set Unicode text information to a shared Clipboard object. Note that such access requires opt-in user permission and is limited to Unicode text data. There are additional restrictions as described in the Clipboard reference topic.
Right-click Mouse Events
Silverlight 4 adds the MouseRightButtonDown and MouseRightButtonUp events to the base UIElement class. Applications can now handle right-click mouse events and change the behavior. Be default, when the user right-clicks a Silverlight application, the Silverlight configuration dialog box opens.
Commanding
In Silverlight 4, ButtonBase and Hyperlink support Command and CommandParameter properties. The Command property can reference an ICommand implementation that comes from a view-model data source, through a {Binding} usage. The command is then interpreted at runtime by the Silverlight input system. For more information, see ButtonBase.Command or Hyperlink.Command.
Implicit Styles
You can now set a Style implicitly. Implicit styles allow you to apply a certain style to all elements of certain type. For more information, see Style or Creating a New Control by Creating a ControlTemplate.
Right-to-Left Flow Direction
You can now set the direction of content and layout of each control to flow from right to left. This enables you to develop Silverlight applications in international languages, such as Hebrew and Arabic. You set the flow direction with the FlowDirection property. For more information, see FlowDirection.
Full-Screen Support
Silverlight now enables applications to remain in full-screen mode when another application is active. For more information, see the FullScreenOptions property.
Multiple Transforms
You can now use the CompositeTransform class to apply multiple transforms to the same object, such as skew and rotate. This class applies multiple transforms in a preferred order and is generally better suited for applying multiple transforms to an object instead of using the TransformGroup class.
Base Element API Changes
In addition to the previous features, the following changes in DependencyObject, UIElement and FrameworkElement may be interesting for UI scenarios:
• The FrameworkElement.Cursor property can now be set with property system APIs.
• FrameworkElement has an Unloaded event.
• Text events for input method editors are supported at the UIElement level, so that you can take advantage of routing.
• SetValue calls are more consistent with WPF equivalent behavior, particularly in cases of running animations.
XAML
________________________________________
Silverlight 4 includes a new XAML parser as part of the Silverlight runtime. The new XAML parser in Silverlight provides the following:
• Greater compatibility with XAML that was originally written for WPF.
• Greater compatibility with the XAML language as defined in the [MS-XAML] specification.
• Enables tools and other XAML consumers to integrate a Silverlight XAML design-time experience in a more predictable way.
To provide the greatest compatibility for Silverlight 3 applications, the Silverlight 4 runtime includes the XAML parser from Silverlight 3. The Silverlight 3 XAML parser is used to load any XAML for applications that specifically target Silverlight 3. The new parser loads XAML for applications targeting Silverlight 4. The two parsers exist side-by-side.
For more information about the differences in XAML behavior between Silverlight 3 and Silverlight 4 XAML parsing, see XAML Processing Differences Between Silverlight 3 and Silverlight 4.
There are some differences between Silverlight XAML and WPF XAML. For more information, see XAML Processing Differences Between Silverlight Versions and WPF.
Data
________________________________________
Data Binding
Silverlight data binding now supports the following features:
• Binding to DependencyObject instances.
• Binding to String indexers.
• Ability to specify String formatting options through the StringFormat property.
• Ability to specify default display values through the FallbackValue and TargetNullValue properties.
• Ability to group collection items through the GroupDescriptions property of the CollectionViewSource class.
• Support for the ICollectionViewFactory interface, which enables custom data-entity collections to provide custom ICollectionView implementations to the CollectionViewSource and DataGrid classes.
• Support for complex, multi-property validation of bound objects that implement the INotifyDataErrorInfo or IDataErrorInfo interface. This includes support for these interfaces by the binding engine and by user-interface controls such as DataGrid.
For more information, see Data Binding.
A new DataServiceCollection class provides simplified binding for data returned by WCF Data Services. This class inherits from the ObservableCollection class to automatically update bound data when there are changes to data in bound controls. For more information, see How to: Bind Data Service Data to Controls (WCF Data Services/Silverlight).
WCF Data Services
The WCF Data Services client for Silverlight enables you to access data from any service that exposes an Open Data Protocol (OData) feed. The following functionality has been added to the WCF Data Services client in this release of Silverlight:
• A new DataServiceCollection class provides simplified binding of data service data to Silverlight controls. This class inherits from the ObservableCollection class to automatically update bound data when there are changes to data in bound controls. For more information, see How to: Bind Data Service Data to Controls (WCF Data Services/Silverlight).
• The WCF Data Services client for Silverlight now supports both out-of-browser and cross-domain execution. For more information, see WCF Data Services (Silverlight).
• The WCF Data Services client for Silverlight now supports explicitly supplying authentication credentials when requesting data from an OData-based service. For more information, see how to: How to: Specify Client Credentials for a Data Service Request (WCF Data Services/Silverlight).
The following new Open Data Protocol (OData) functionality is supported by the WCF Data Services client in this release of Silverlight:
• An OData service can return only the total number of resources represented by a URI or include this row count information together with the resource data in a single response. The WCF Data Services client for Silverlight has been updated to enable you to access this row count information in a query response in your application. For more information, see Querying the Data Service (WCF Data Services).
• A data service can be configured to return requested resources as a set of paged responses. The WCF Data Services client for Silverlight has been updated to enable you to handle such paged responses. For more information, see Loading Deferred Content (WCF Data Services).
• Query results returned by an OData service can now be projected into arbitrarily defined types. The WCF Data Services client for Silverlight has been updated to support projection by using the select clause (Select in Visual Basic) in a LINQ query. For more information, see Query Projections (WCF Data Services).
• The WCF Data Services client for Silverlight has been updated to let you get and set binary properties as a stream from an OData service that supports media resources. For more information, see Loading Deferred Content (WCF Data Services).
Application Model
________________________________________
WCF RIA Services
WCF RIA Services simplifies the development of n-tier solutions for Rich Internet Applications (RIA), such as Silverlight applications. A common problem when developing an n-tier RIA solution is coordinating application logic between the middle tier and the presentation tier. RIA Services solves this problem by providing framework components, tools, and services that make the application logic on the server available to the RIA client without having to manually duplicate that programming logic. RIA Services works with Silverlight 4 but is available as a separate installation. For more information, see WCF RIA Services.
Navigation Extensibility
You can extend the Silverlight navigation in order to support arbitrary URI resolution. For example, you can implement navigation extensions for URI redirection, dynamic page generation, and on-demand download of pages from the server.
The Frame and NavigationService classes also provide a Refresh method. This is useful when using navigation extensions that can deliver different content for the same URI depending on user interactions in a particular page. For example, this enables some navigation scenarios with pages that require user authentication.
For more information, see Navigation Overview.
Dynamic Language Runtime
The dynamic language runtime (DLR) is a new runtime environment that adds a set of services for dynamic languages to the CLR. To support the DLR, the new System.Dynamic namespace is added to the .NET Framework and the expression trees are extended with new types that represent control flow, for example, LoopExpression and TryExpression.
For more information, see Dynamic Language Runtime Overview.
Core
________________________________________
Collection Classes
The new ISet interface provides for the abstraction of sets. Sets are collections that have unique elements and specific operations. ISet is implemented by the HashSet class that is now available for Silverlight-based applications.
Tuples
Silverlight 4 provides the Tuple class for creating tuple objects that contain structured data. It also provides generic tuple classes that have from one to seven type parameters for representing singletons, pairs, triples, quadruples, and so on. To support tuple objects that have nine or more components, there is a generic tuple class with seven type parameters and an eighth parameter of any tuple type.
Parsing and Formatting Time Intervals
To support culture-sensitive formatting, the TimeSpan structure now implements the IFormattable interface and includes new overloads of the ToString, Parse, TryParse, ParseExact, and TryParsExact method. Its formatting and parsing methods also support both standard and custom format strings.
Other Core Features
The following list describes new capabilities and improvements added to Silverlight. Several of these are based on customer suggestions.
• The new String.IsNullOrWhiteSpace method indicates whether a string is null, empty, or consists only of white-space characters. New overloads have been added to the String.Concat and String.Join methods that concatenate members of System.Collections.Generic.IEnumerable collections.
• The String.Concat method lets you concatenate each element in an enumerable collection without first converting the elements to strings.
• The StringBuilder.Clear method make is easier to clear a StringBuilder instance.
• The new Enum.HasFlag method determines whether one or more bit fields or flags are set in an enumeration value. The Enum.TryParse method returns a Boolean value that indicates whether a string or integer value could be successfully parsed.
• Trusted applications can use the new Path.Combine method overloads that enable you to combine file paths.
• New file enumeration methods can improve the performance of trusted applications that access directories or that iterate through the lines in large files. Only the directories and files under My Documents are accessible. For more information, see the Directory, DirectoryInfo, and File classes.
• You can now enable lazy initialization for any custom type by wrapping the type inside a System.Lazy class.
• The new Monitor.Enter(Object, Boolean) method overload takes a Boolean reference and atomically sets it to true only if the monitor is successfully entered.
• The System.Guid structure now contains the TryParse and TryParseExact methods.
Silverlight Designer
________________________________________
In Visual Studio 2010, various designer improvements have been made to help create Silverlight applications. In Visual Studio 2008, the designer support for Silverlight projects was limited. In Visual Studio 2010, you can now complete tasks, such as selecting and positioning items with the mouse on the design surface, and setting properties with the Properties window. For more information, see Silverlight Designer for Visual Studio 2010.
Windows Phone Platform Support
________________________________________
Silverlight is now supported on Windows Phone 7 Series in a Community Technology Preview (CTP). For additional information, see Silverlight for Windows Phone and Windows Phone Development.

Source : http://msdn.microsoft.com

No comments:

Post a Comment