[Original] Silverlight series tutorial [1]-WPF/Silverlight architecture and Operating Mechanism

Source: Internet
Author: User

1. Introduction to WPF and Silverlight

At the beginning of this tutorial, we will first understand what is WPF and Silverlight. This is very important. Only by fundamentally understanding this concept, so that we can thoroughly understand what it can do and what it is suitable.

The definition of WPF is defined in msdn as follows: "WPF is the next-generation Display System, used to generate Windows client applications that can bring users an amazing visual experience.Program. With WPF, you can create a wide range of independent applications and applications hosted by browsers ."

The Silverlight definition is defined in msdn as follows: "Silverlight is a cross-browser and cross-platform. net Framework implementation, used to generate and provide the next-generation media experience for the web and rich interactive applications (RIA ). Silverlight unifies server, web, and desktop functions, and managesCodeAnd Dynamic Language, Declarative Programming and traditional programming, as well as Windows Presentation Foundation (WPF) features ."

From the above definition, we can see that either WPF or Silverlight is used to provide a new technical framework for the interface layer to support Ria. With the support for Ria, this represents that the technology of the next-generation UI Layer is also integrated with a series of related technologies and concepts, such as XAML, Declarative Programming, dependency attributes, routing events, data binding, and multimedia support.

In fact, there are a variety. NET developers, it is easy to learn Silverlight and WPF as long as they grasp several important concepts, this series of courses focuses on this series of key concepts.

Ii. Differences between WPF and Silverlight
In the early days, Silverlight was not called Silverlight or WPF/E. From this name, we can also see its origins with WPF. This should be Microsoft's strategy, that is, WPF provides a desktop-based development framework, while WPF/everywhere supports browsers and supports cross-platform and cross-browser access. But later I got this awesome name "Silverlight ".

Different functions and implementations based on these features (WPF provides support for client applications, while Silverlight runs cross-platform and expanded browsers through browsers or other hosts ), their architecture is also different.

The basic difference is:

The running of WPF requires the. NET runtime and the installation of the. NET Framework framework. Currently, the. NET Framework only supports Windows platforms, which limits that WPF can only run on Windows platforms. For Silverlight, an installation package needs to be installed. In fact, this installation package is also a miniature version. net framework. the package size is about 3 MB. After We decompress silverlight.exe with WinRAR, we can see that some of the packages are in it.. Net DLL, Which is required when Silverlight is running. One of the most important DLL is coreclr. dll, which is responsible for providing. Net runtime in the host, so Silverlight is not installed on the local machine. NET Framework. This is why Silverlight does not require the client to install. NET Framework, because it provides. NET Framework.

Note that although the DLL name in the Silverlight package is the same as that in the. NET Framework DLL name, The dll version number, internal implementation, and size are different. Why? As we all know, the Silverlight installation package needs to be downloaded and installed. If the package is too large, it is definitely not suitable. So in order to compress. net framewrok core DLL, such as system. core. DLL, system. some classes that cannot be used by Silverlight, such as DLL, are removed (I guess O (pipeline _ runtime) O ). Therefore, Silverlight has fewer class implementations in DLL with the same name. So don't be surprised when you find that common classes or methods cannot be found during Silverlight programming. For example, many XML operation classes are not available in the Silverlight framework. This series of tutorials will be designed later. Please stay tuned to the series of windstore tutorials .:)


Iii. Architecture of WPF and Silverlight

The WPF architecture is as follows:

(Figure 1)

(Figure 2)

From the above we can see that the WPF architecture is relatively pure, while the red is the WPF-related components, while the blue is the Windows system itself, and has nothing to do with the WPF framework.

In the blue component:

USER32, kernel, and DirectX provide basic component libraries for the windwos platform, which are basically used by applications on the Windows platform.

CLR provides the runtime environment of the. NET Framework.


There are three red WPF-related components:

Presentationframework and presentationcore provide all the functions related to the WPF technology environment and class library support.

Milcore is a non-hosted DLL and is part of the WPF component. It is mainly used to interact with DirectX in WPF. All rendering, animation, 2d, and 3D graphics in WPF use this class library to interact with DirectX. As to why the code is not hosted, it is mainly based on performance considerations, because interface rendering is the foundation of WPF technology, it has high performance requirements.


 The Silverlight architecture is as follows:

Compared with WPF, The Silverlight framework is not so simple and even complicated. Since WPF is based on the. NET Framework framework, it only provides support for its presentation layer functions. Silverlight provides an independent environment, including the core layer representation, CLR, and ,. net, API support for interaction with the host, XAML parsing, communication framework, and WPF control support. Therefore, many people say that silvrlitht is simple because the presentation layer function of Silverlight is much less than that of WPF, but in fact its entire framework is much more complicated than WPF.

Now, let's take a look:

The Silverlight framework can be divided into the following parts:

1. browser and host

This part mainly provides the Silverlight host requirements, including a series of features of the browser, the Silverlight installation package itself. This part is closely related to Silverlight and serves as a link for interaction with Silverlight.

2. Core Components of the Presentation Layer

This layer is the core part of Silverlight and is mainly responsible for receiving user input, multimedia processing, XAML resolution, and UI rendering. This layer is particularly different from WPF, similar operations of WPF are implemented by their own class libraries. However, this part of Silverlight is composed of an unmanaged class library agcore. DLL. This class library is responsible for most of the functions related to Silverlight rendering, as well as Interface interaction between the Silverlight hosting environment and the host (such as a browser.

3. XAML Section

Needless to say, XAML is mainly responsible for presentation and serves as a bridge between the. NET Framework and the presentation layer core.

4.. Net Runtime

When providing. Net runtime, as mentioned earlier, it is implemented by coreclr. dll.

5. Other. Net related class libraries (such as WPF control libraries, WCF, LINQ, DLR, and JS managed APIs)

These are all affiliated class libraries in the Silverlight framework, mainly providing relevant. NET technology support, such as WCF, WPF controls, DLR, and LINQ. these are independently stripped out as part of the Silverlight framework.

Next, let's take a look at how the entire Silverlight framework interacts:

In this figure,

The browser acts as the host for the entire Silverlight operation,

After being loaded by the browser, the Silverlight plug-in performs a series of actions, such as calling the core service, initializing the. NET runtime environment, and downloading the. xap package from the server.
Among them, the core service is mainly used to provide interaction between the host and Silverlight, which has been supported by the underlying Silverlight. For example, the core presentation layer is provided by the core service. Mainly agcore. DL.

In fact, as long as you understand that the entire Silverlight framework is completely different from the complete. NET Framework framework of the local machine, it is not difficult to understand this. From the framework structure above, we can see that Silverlight and WPF are somewhat similar, such as XAML, controls, and some mechanisms (such as routing events and dependency attributes ), however, the underlying framework structure and implementation are basically completely different. Let's talk about it here first. It's a bit messy.ArticleIf you have any questions, please leave a message.


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.