Export (0) Print
Expand All
5 out of 5 rated this helpful - Rate this topic

Application Model

Silverlight

The Silverlight application model provides the following functionality for use by managed applications:

  • An activation system, which enables the Silverlight plug-in to download the application package and any external library assemblies that your application needs at startup.

  • An Application class, which encapsulates services commonly required by Silverlight-based applications, such as life-cycle event notification and an interface to the Silverlight plug-in.

  • An application extensibility system, which encapsulates additional services that are required by some applications, such as a customized data access layer.

  • A resource management system, which includes URI referencing and fallback mechanisms, on-demand resource loading, style and template sharing, and globalization support.

These features enable you to implement well-factored application structures that provide a balance between startup time and resource availability.

For example, you can implement an application that provides immediate access to a small, initial set of pages, but downloads other pages on demand. Alternately, you can provide a large initial download and display a splash screen to maintain responsiveness. If you provide a large initial download, you can reduce subsequent download times by using application library caching. Finally, you can implement a custom navigation system as an application extension service.

The Silverlight activation system enables you to specify which assemblies and resource files to include with your application. The build system bundles the specified files into an application package, which is a compressed zip file that has a .xap file extension.

You can reduce the size of the application package by using application library caching. In this case, the assemblies configured for caching are compressed into separate zip files. These assemblies are called ExternalPart assemblies.

The application package includes a manifest file that identifies all the assemblies that your application can use. This includes:

  • Assemblies in the application package.

  • ExternalPart assemblies, which are downloaded at startup and then cached.

  • Assemblies that you might download after startup.

At a minimum, the application package must also include the assembly with your application class, which the Silverlight plug-in instantiates. When your application starts, it can perform tasks such as displaying a user interface or retrieving additional resources.

You must decide which assemblies and resource files to deploy in the application package, as ExternalPart assemblies, or for retrieval after startup. One common workflow is to put everything in the application package, and then measure the download and startup times as your application becomes larger. When the delay becomes significant, you should consider providing a splash screen, using application library caching, and retrieving some files after startup.

For more information about the Silverlight activation system and the options for factoring your application, see Application Structure.

The Application class provides services in the following categories:

  • Application Startup and Exit events.

  • Interaction with the Silverlight plug-in and the host Web page.

  • Resource management.

  • Centralized exception handling.

All Silverlight-based applications must include a single class derived from Application. Your application class will typically add XAML-based, application-wide resources and handle the Startup event to provide a user interface. The Silverlight plug-in displays the user interface in its client area as configured in the host Web page.

You can use the Startup event to initialize your application and its user interface. For example, you can specify the initial application state based on Silverlight plug-in configuration parameters, URL parameters, or user settings retrieved from isolated storage.

You can also use the Startup event to begin asynchronous downloads of additional assemblies and resource files. The Application class provides a helper method for extracting resources from the assembly package or downloaded zip files.

For more information, see Application Services.

The Application class enables you to add more services by populating its ApplicationLifetimeObjects property. You can do this in your application XAML or with procedural code in the application constructor.

The ApplicationLifetimeObjects property is a list of objects that implement IApplicationService and optionally IApplicationLifetimeAware. These two interfaces provide access to multiple stages of the application lifetime. IApplicationService enables you to initialize and clean up your services. IApplicationLifetimeAware extends IApplicationService, and enables you to implement more complex dependencies among services and between services and application code.

For more information, see Application Extension Services.

Silverlight supports the following kinds of resources:

  • XAML resources, such as styles and templates that you can share among multiple user interface elements.

  • Resource files, such as images and videos that you can refer to by URI. You can embed resource files in assemblies, include them separately in the application package, or retrieve them from the network.

  • Resource strings and other values embedded in your assemblies or provided through localized satellite assemblies.

In general, the phrase resource file can refer to any file that supplements your application assembly. This can include data files or library assemblies that contain other kinds of resources, such as localized strings or XAML files.

You can reference some resource files by URI, such as images. These can be absolute URIs to retrieve files from anywhere on the Web, or they can be relative URIs. Silverlight uses a fallback mechanism for relative URIs so that you can change where some files are deployed without having to change code.

You can retrieve some file types, such as zip files and assemblies, only from the site of origin by using an asynchronous download process. You can use the Application class to extract resources from zip files, and you can use the AssemblyPart class to load assemblies.

For more information, see Resources Overview.

Silverlight provides several options for navigating within your application or to resources that are external to your application.

For application navigation, you use Frame and Page controls. The frame acts as a container for page controls, and facilitates navigation to pages. Each page contains content and you add as many pages as needed to represent the content to the user. At any one time, the frame displays the content of a single page. For external navigation, you can provide ordinary hyperlinks in your user interface or perform programmatic navigation through the HTML DOM.

For more information about browser and application navigation options, see Navigation Overview.

Silverlight provides splash screen support so that you can customize the default experience during the download and startup of managed applications. The default splash screen shows a simple spinning animation after a short delay.

If your application package requires significant download and startup time, you might want to replace the default splash screen with one that shows download progress. You can also use the splash screen to describe your application or provide instructions, credits, or disclaimers.

Silverlight splash screens are implemented by using the JavaScript API. This enables the Silverlight plug-in to display your splash screen immediately, even before loading the Silverlight managed runtime. You can change your splash screen programmatically by using browser-interpreted JavaScript in your host Web page.

For more information, see Silverlight Splash Screens.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.