Silverlight's JavaScript API

Source: Internet
Author: User
Tags wrapper silverlight

In some cases, the Silverlight JavaScript API is required or more appropriate than the managed API. This topic discusses these situations and provides links to more information about the JavaScript APIs in Silverlight.

Prerequisite

You should read the application and programming models and understand the basic differences between the managed APIs and the JavaScript APIs. You should also understand how the HTML DOM and the Silverlight programming model and Object tree are related to the browser DOM;

Programming Model Considerations

Silverlight's JavaScript API is the programming model that has been provided in Silverlight version 1.0. It uses a small subset of the objects currently provided in Silverlight 2, plus a small number of objects that are specific to the JavaScript API. The subset considerations also affect objects that can be defined in XAML. The Silverlight XAML parser creates objects in the object tree for this subset only, because the object tree is created based on a fixed native code implementation located under the JavaScript API. In other words, a subset of the JavaScript API that applies to Silverlight and limitations considerations are far more meaningful than the language chosen to write code-behind logic; the programming model you choose/API determines which objects are available for your application.

If you have developed for Silverlight 1.0, you may already be familiar with the JavaScript API for Silverlight. The JavaScript API is very similar to programming for HTML Dom and is actually performed in the browser's scripting engine, just like a DOM script, but the Silverlight model extends to loading the contents of a XAML page as a Silverlight plug-in The object tree created when the This allows you to handle events on specific objects defined in XAML, get or set property values or Execute object methods at run time, modify the structure of objects created by XAML, and so on at run time.

In terms of structure, you should enable the JavaScript API on the Silverlight plug-in by opening the path to the Silverlight object tree, wrapping the script calls, and passing them to the plug-in object on the local machine. In Internet Explorer, this wrapper is implemented through a IDispatch::Invoke call, and other browsers can use different wrapper paradigms based on their plug-ins and script structure.

Scenarios using the JavaScript API

splash screen

The splash screen is an initial content area that can be displayed to the user while other content is still loading. In terms of design and use, the splash screen has a relatively low user interface and interaction requirements. The splash screen is mainly used in the following areas:

Show an appealing visual effect.

Provide feedback to the user that the application (or browser host) is still working as expected and that the download is in progress.

Provides specific information about the progress of the download.

The first two features are often fully implemented in XAML without any code-behind. Provides a relatively small API for download progress to obtain information from the network layer that performs the download. For these reasons, it is best to implement the splash screen by using the JavaScript API and loading a XAML page for SplashScreenSource (which is supported by script code-behind). The JavaScript API can load the splash screen without activating the Silverlight CLR and related assemblies, which shortens startup time.

Related Article

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.