简体   繁体   English

什么是Silverlight插件?

[英]What's a Silverlight plugin?

Please explain what a Silverlight plugin is. 请说明什么是Silverlight插件。 Is it a single xap file, a xaml file, a dll, or what? 它是单个xap文件,xaml文件,dll还是什么? Please elaborate. 请详细说明。

Note: by “Silverlight plugin”, I mean one a developer would make for the browser and for Silverlight, not the Silverlight browser plugin itself. 注:“Silverlight的插件”,我的意思是一个开发将使在浏览器 Silverlight ,而不是浏览器的Silverlight插件本身。

The Silverlight plugin is the software that allows you to run Silverlight applications in the browser. Silverlight插件是允许您在浏览器中运行Silverlight应用程序的软件。

Ie if you're writing some code to be run in the browser by Silverlight, you're writing a Silverlight application, not a Silverlight plugin. 即,如果您要编写一些要由Silverlight在浏览器中运行的代码,那么您是在编写Silverlight应用程序,而不是Silverlight插件。

The Silverlight plugin can be downloaded here. 可在此处下载 Silverlight插件

Now that we settled what the Silverlight plug-in is vs. a Silverlight application (see Robert Harvey's answer), here is some more info on what makes up a typical Silverlight application: 既然我们已经确定了Silverlight插件与Silverlight应用程序的区别(请参见Robert Harvey的答案),下面是一些有关组成典型Silverlight应用程序的信息:

The application itself will be a XAP file (really a zip) that contains compiled assemblies. 该应用程序本身将是一个XAP文件(实际上是一个zip),其中包含已编译的程序集。 The assemblies are like regular .NET assemblies, but work only under Silverlight (there are ways to build a single assembly that could work under real .NET and Silverlight, but there a ton's a restrictions, let's just ignore that). 程序集就像常规的.NET程序集一样,但是只能在Silverlight下工作(有多种方法可以构建可以在实际的.NET和Silverlight下工作的单个程序集,但有很多限制,让我们忽略它)。 The XAP contains assemblies you wrote and all those you've referenced. XAP包含您编写的程序集以及您引用的所有程序集。 The plug-in downloads this XAP, opens it up, and runs that code. 插件下载此XAP,将其打开并运行该代码。 Normally you have one XAP file per application. 通常,每个应用程序只有一个XAP文件。 (but you can download and load code in other XAPs if you want - some Slightlight frameworks do this, Prism for one). (但是您可以根据需要在其他XAP中下载并加载代码-一些Slightlight框架可以这样做,Prism就是其中之一)。

Besides the assembly DLLs, there is a manifest file in the XAP and other "stuff" you may want to be outside the complied code. 除了汇编DLL之外,XAP中还有一个清单文件,您可能希望其他文件不包含在编译代码中。 For example, we have some extra configuration files inside our XAP. 例如,我们的XAP中有一些额外的配置文件。 I guess the idea is that you can unzip the XAP on the hosting web site, change a setting, and rezip it. 我想这个想法是,您可以在托管网站上解压缩XAP,更改设置,然后将其重新压缩。 I'm not sure if people put other things in the XAP (images?). 我不确定人们是否在XAP中放置了其他东西(图像?)。 We normally rely on http get calls to download "stuff" from the host web site and/or via web service calls. 我们通常依靠http get调用从主机网站和/或通过Web服务调用下载“资料”。

You asked about XAML: Silverlight renders UI via tree of visual elements (like a web page). 您询问了XAML:Silverlight通过可视元素树(如网页)呈现UI。 Normally you define this by including/compiling XAML markup files into your assemblies (they aren't loose inside the XAP). 通常,您可以通过将XAML标记文件包含/编译到程序集中来定义它(它们在XAP中并不松散)。 The XAML is mostly presentation (like html) but has some basic "programmability" (animations is the only good example I can think of). XAML主要是表示形式(如html),但具有一些基本的“可编程性”(动画是我能想到的唯一好例子)。 You will normally be writing procedural code (C#) to make the application "come alive". 通常,您将编写过程代码(C#)以使应用程序“活跃起来”。 The interaction between the code and markup is where things get interesting (UserControls, Pages, custom Controls, binding, converters, behaviors, triggers). 代码和标记之间的交互是使事情变得有趣的地方(用户控件,页面,自定义控件,绑定,转换器,行为,触发器)。

Visual Studio will generate an ASP.NET web site to host your silverlight application. Visual Studio将生成一个ASP.NET网站来托管您的silverlight应用程序。 There isn't anything special about it other than it provides sample code on you to setup the plug-in, point it to your app, and how to handle installing the plug-in for browsers without it. 除了为您提供用于设置插件,将其指向您的应用程序的示例代码以及如何为没有该插件的浏览器安装插件的示例代码外,它没有什么特别的。

It is a 'dll' that is installed in your browser. 这是您的浏览器中安装的一个“ dll”。 It allows the user to execute the xaml code, which is located in a XAP file. 它允许用户执行XAP文件中的xaml代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM