Silverlight: Application and Programming models

Source: Internet
Author: User
Tags html page object model resource silverlight

Most Silverlight-based applications are written in managed code and take full advantage of the Silverlight application model. However, you can choose to use a simplified programming model.

Silverlight provides the following two distinct models for application development:

Silverlight's managed API, which uses code that runs on the common language runtime (CLR) of Silverlight. You can use the managed APIs for compiled languages such as Visual Basic and C #, or for dynamic languages such as IronPython and IronRuby.

Silverlight's JavaScript API, which uses JavaScript code interpreted by the browser.

These programming models are very different because you cannot use them at the same time in a single instance of the Silverlight plug-in. However, you can implement the splash screen using the JavaScript API and then transition to the managed API when you load your application.

The managed API provides a lot more functionality than the JavaScript API, which is covered in most Silverlight documents. Applications that use the managed APIs can access lightweight versions of the. NET Framework, while JavaScript APIs can access only the Silverlight presentation core and the browser JavaScript engine.

Managed programming and Application models

The managed API allows you to package managed assemblies and resource files as application package (. xap) files. The Silverlight plug-in is responsible for loading the application package and extracting its contents.

The application package must contain an assembly that has a class derived from application. The application class encapsulates the interaction between your application and the Silverlight plug-in. For example, it allows you to display a user interface within a host Web page. In addition, it provides application lifetime events and resource management.

Silverlight documents use the term "application model" to refer to the application packages and public functions encapsulated by the application class. The application model helps you develop simple applications and complex, extensible applications that can share network resources.

These application model topics provide guidance on designing applications to support several common situations, such as loading resources as needed, downloading progress instructions, and navigating.

Managed APIs

You can use XAML markup to encapsulate your user interface (UI) design in the managed APIs and JavaScript APIs. When you use the managed APIs, you can distribute application code to multiple XAML files and accompanying code-behind files.

When the Silverlight plug-in loads a XAML file, it creates an object tree that your code-behind can manipulate. Your managed application code can also manipulate the HTML Document Object Model (DOM) through HTML Bridge.

JavaScript API

The JavaScript API is the model available in Silverlight version 1.0, reserved for backward compatibility to support some special cases.

In the JavaScript API, the Silverlight plug-in loads a single XAML page rather than an application package. This XAML can include URI references to server-side resources such as images and video. The Silverlight plug-in creates an object tree using XAML, and you can manipulate the object tree programmatically by using JavaScript in the Host HTML page.

The JavaScript API does not provide an application model that supports complex applications with internal navigation capabilities. However, it supports situations that are inconvenient to use the managed APIs, such as the splash screen. You can also implement basic navigation by loading a new XAML page into the Silverlight plug-in or by loading a new Web page into a browser.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.