Google News
logo
Silverlight Interview Questions
Microsoft Silverlight is a powerful tool for creating and delivering rich Internet applications and media experiences on the Web. Silverlight 5 builds on the foundation of Silverlight 4 for building business applications and premium media experiences. Silverlight 5 introduces more than 40 new features, including dramatic video quality and performance improvements as well as features that improve developer productivity.
Silverlight is an open – source development tool manufactured by Microsoft, which is essentially used to create and deploy interactive user experiences along with media and internet applications for various internet and mobile applications.
XAML language is used to design the layout of Silverlight. XAML stands for Extensible Application Markup Language. It is a declarative XML-based language created by Microsoft.
To run Silverlight applications in a web browser, you need to have the Silverlight runtime installed on the client browser as a plug-in. This is a light-weight version of the .NET runtime.
 
However, to develop a Silverlight application, you need something more.
 
Silverlight SDK : This includes a set of tools required to compile and build Silverlight controls.
 
If you are comfortable writing HTML using Notepad and compiling .NET applications from console tools, then you just need the Silverlight SDK to develop Silverlight applications.
 
However, most people use some kind of IDE to develop applications faster.
 
Microsoft offers two separate tools to develop Silverlight applications :
 
• Microsoft Expression Studio - This tool is meant for web designers to create rich visual elements for Silverlight applications. Expression Studio is recommended for web designers who create rich internet applications with enhanced visual content and graphics. There are several features provided for creating enhanced graphics elements, with lot of options to pick color, font, etc. 
 
• Microsoft Visual Studio - This is the integrated development environment from Microsoft to develop .NET applications. Programmers can use Visual Studio to develop Silverlight applications which require programming. Visual Studio allows programmers to develop sophisticated Silverlight applications in any .NET language (like C#, VB.NET etc). 
 
Here are some other tools that you can use :
 
• Install Deep Zoom Composer - This tool allows you to prepare your images for use with the Deep Zoom feature in Silverlight 3. 
 
• Download Silverlight Toolkit - This toolkit is a Microsoft project containing Silverlight controls, components, and utilities that can be downloaded and used in your Silverlight applications. It includes full source code, samples, and tests. 
 
• Download .NET RIA Services - Microsoft .NET RIA Services simplifies the traditional n-tier application pattern by bringing together the ASP.NET and Silverlight platforms. RIA Services provides a pattern to write application logic that runs on the mid-tier and controls access to data for queries, changes, and custom operations. 
No, Silverlight project doesn't support normal ADO.NET objects like DataTable, DataSet, DataColumn, Database connection providers like SqlConnection, OledbConnection objects.
 
You can use System.Data namespace but that contains Services related stuffs not ADO.NET stuffs.
Styles elements are supported in the form of application resources. An app.xaml file can be created containing an application resource Xml construct. The target type for each style is set to the control on which the style needs to be applied.

App.xaml :
<Application.Resource>
<Style x:Key="MyBorder" TargetType="Border">
<setter property="width" value="5">
</style>​


Page.xaml :
<Border Style="{StaticResource MyBorder}">
...
</Border>​
RIA is an acronym stands for Rich Internet Applications. These are web application with rich features. These features include built in AJAX support, layouts, animations, audio, and video components.
The four different components used in Silverlight :
 
* Silverlight Plug-in

* Silverlight Host, the Web Page

* Silverlight Application File (.XAP)

* The Interface language, XAML
There are several files that are required to be used in silverlight to make it function properly and to include the properties of applications together :
 
AppManifest.XAML : It consist the list of all the entry points including the class and assembly. This file can be taken and hosted in any HTML file using an object tag.
 
The code will be given as :
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2"   
width="100%" height="100%"><param name="source"   
value="MySilverLightControl.xap"/></object> ​
 
Silverlight.js and CreateSilverlight.js : contains the initialization of the Silverlight plug-in that will be used in HTML pages.
The architecture of Silverlight is made of three components :
 
Core presentation framework : This framework includes the components like data binding, vector graphics, text, animation, images for presenting various features.

.NET framework for Silverlight : It includes the libraries and components like XLINQ, XML serialization, Syndication, base class libraries, networking and common language runtime.

Updater and Installer : It is a control for installation and provides automatic updates.
We can either use Visual C# or Visual Basic to code the backend of  the silverlight application. Here backend means the code behind files for the Sivlerlight pages.
Silverlight Windows Presentation Foundation (WPF)
It is a subset of WPF. All Silverlight features are also incorporated in WPF.
Silverlight is used for the development of premium browser-based internet applications. WPF is utilized for the development of graphical applications for the development platform.
In order to change the startup page of any particular Silverlight application, firstly open the App.xaml.cs file. Subsequently in the Application_Startup handler, set the RootVisual property to the particular Silverlight class. Consider the following example :
 
In order to find the file name : MainPage.xaml, there must exist a class known as MainPage with MainPage.xaml.cs
private void Application_Startup (object sender, StartupEventArgs)
 
{
 
this.RootVisual = new MainPage();
 
}
Silverlight plug-ins comes with the following features :
 
* Presentation Engine
* XAML Parser
* .NET Parser
* .NET Framework
* Media Features
* Browser Interaction
* Downloader
.xap file is a compressed file for the Silver Application. It contains AppManifest.xaml, compile output assembly of the Silverlight project (.dll) and any other resources by the Silverlight application. Visual studio creates two files while creating project; App.xaml and Page.xaml.
The .xap file is used to contain and transfer the assemblies and resources of a managed code application. This managed code application should be run within the Silverlight 2 browser plug-in.
Following are the two important tools required to build Silverlight applications :
 
Microsoft Expression Studio : This tool is used by web designers to create rich visual elements for Silverlight applications with enhanced visual contents and graphics.

Microsoft Visual Studio : This tool is used by programmers whose application is based on logic or requires programming. It permits programmer to build Silverlight applications in any .NET language like C#, Visual Basic.NET, etc.)
These two .NET applications are supported in Silverlight :
 
* Embedded Common Language Runtime (CLR)

* .NET Framework Libraries
You can host a Silverlight application on most types of web server like Apache and IIS (Internet Information Server). If you want to host Silverlight application from your web server, you need to allow the following MIME type.
Extension MIME Type
.XAML Application/ XAML+XML
.XAP Application/ Silverlight-app
The simple steps involved in consuming WCF in Silverlight include :
 
* Creation of WCF service
* Enabling the cross-domain required for WCF service
* Addition of WCF service reference
* Calling the service
The different XAML files generated when a new project in Silverlight Visual Studio is created include :
 
App.xaml : A file that is utilized in order to declare shared resources such as brushes, different style objects, etc. and to handle various global application events at different levels. The following events are created when using the App.xaml.cs file :

Application_Startup
 
Application_Exit
 
Application_UnhandledException
 
ReportErrorToDOM
 
MainPage.xaml / Page.xaml : This file is used as a default page by the Silverlight application especially when a Silverlight application is running.
Isolated storage is a virtual file storage system in Silverlight which is used to store data in a hidden folder on your system. It stores the data in a two separate sections:
 
Section1 : It contains the administrative information like disk quota.

Section2 : It contains the actual data.

Each Silverlight application is allocated its own portion of the storage with the current quota set to be 1 MB per application.
The Silverlight application can be shown in full screen mode by using the following command :
 
Application.Current.Host.Content.IsFullScreen = true;
Deep Zoom is one of the functions of Silverlight which is used to zoom in and zoom out of the application.
The ClientBin folder is used in ASP.NET application to use the Silverlight functionalities. The ClientBin folder contains the .xap file that contains the reference of the Silverlight libraries which is later used in ASP.NET applications.
Yes. It is possible to pass parameters from your aspx pages and HTML pages to the Silverlight controls by setting InitParameters.

The XAML page user control has a property known as InitParameters. From your ASPX pages, you can set a value in the form of key value pairs. Since this property accepts key-value pairs, you can pass any set of string values.
Silverlight 1.0 Silverlight 2
All the code has to be purely written in JavaScript and XAML. There is no such specification for Silverlight 2.
The XAML code is directly referenced by the object embedded with the browser. The embedded object is referenced using the XAP packages that essentially contains the XAP files, resources and assemblies
Silverlight SDK is a set of instruments, documentation, tests, and layouts for web designers. It is mainly used to empower them to effectively create Silverlight enabled applications. The SDK is not generally obligatory to create Silverlight applications. However, the SDK will make an improvement in a very effective and efficient manner.
You can check the internet connection status by using the following code :
 
If (NetworkInterface.GetIsNetworkAvailable())  
{  
Messagebox.Show("Network available");  
}  
else  
{  
Message.box.Show("Network not available");  
}​
  
Silverlight.js is a helper file which enables websites to create advanced Silverlight installation and instantiation experiences. You can call the createObject and createObjectEx functions defined in this file to embed the Silverlight plug-in in a web page.
First, let’s look at an example AppManifest.xaml file : Collapse The first element in AppManifest.xaml is a Deployment node. This node defines the application, and contains the child AssemblyPart nodes. As you can see the AssemblyPart nodes define what assemblies (DLLs) are contained within the .xap file, and give each of them a name. Now, if you look back up to the top, you'll see the Deployment node has the EntryPointAssembly and EntryPointType attributes. The EntryPointAssembly attribute defines which assembly defined below (as a child AssemblyPart node) is the main assembly (DLL) for the application. And, the EntryPointType attribute specifies the class contained within the assembly (DLL), defined in the EntryPointAssembly attribute, is the main class that will be instantiated to start the application. The Deployment node also has a RuntimeVersion attribute that defines the version of Silverlight the application is built for. 
When you create a Silverlight project using Visual Studio, it creates a default XAML file called "MainPage.xaml". This is just a dummy start page created by Visual Studio, and it does not contain any visible UI elements. The default contents of the MainPage.xaml file looks like this: Collapse 
Adobe Flash is the most popular competitor to Silverlight, supporting browser plug-ins and enabling the execution of rich content for the Web. Flash is not a new technology, and already has had a long life span as compared to Silverlight. But it does not have a huge community as expected; it may be because of the limited development tools which are not known to most developers. Flash uses ActionScript as the programming language and Flex as the programming environment, and most developers are far from these technologies. For ASP.NET developers, to extend their websites using Flash content is not so simple. They need to learn a development environment like ActionScript and Flex. Apart from that, there is no way to generate Flash content using server-side .NET code, which means it’s difficult to integrate ASP.NET content and Flash content. Silverlight aims to give .NET developers a better option for creating rich web content. Silverlight provides a browser plug-in with many similar features to Flash, but one that’s designed from the ground up for .NET. Silverlight natively supports the C# language, and uses a range of .NET concepts. As a result, developers can write client-side code for Silverlight in the same language they use for server-side code (such as C# and VB), and use many of the same abstractions (including streams, controls, collections, generics, and LINQ).
Technically, Silverlight and ASP.NET are completely different. The major differences are listed below : 
 
• Silverlight runs completely on the client, while ASP.NET mainly runs on the server, but also has a few parts running on the client. 
 
• When an event fires, Silverlight handles the event on the client, but in ASP.NET, the browser will make an HTTP POST to the server, and after the server handles the request, it sends a new HTML page to the client. 
 
• A Silverlight application sends rendering commands to the Silverlight rendering engine by either writing XAML or code, and the Silverlight rendering engine will handle the rendering task. On the other hand, ASP.NET doesn’t have a rendering engine. It generates an HTML file on the server, sends it to the client, and allows the browser to parse the HTML file and render the content. 
 
• Silverlight can’t work with a database directly; instead, it consumes data from Web Services, while ASP.NET has strong support for working with databases directly. The most important thing to note is what runs on the client and what runs on the server, since this will affect almost every part of your system. Silverlight runs on the client, and ASP.NET runs on the server. They can work together and are compatible with each other, but this requires some time and effort. 
• Support for Google's Chrome browser. 
 
• Web cam and microphone support. 
 
• Printing support. 
 
• Full keyboard access while running in full-screen mode. 
 
• Programmatic access to a user's local document folder. 
 
• Improved mouse support, including right button support and mouse wheel support. 
 
• Elevated trust and support for local Component Object Model (COM) objects. 
 
• New notification support to display messages to end users. 
 
• New and enhanced controls such as a RichTextBox and an enhanced DataGrid control. 
 
• New support for implicit theming of controls. 
 
• New hosted browser support for rendering HTML inside Silverlight. 
 
• WCF data layer enhancements. 
 
• Localization enhancements with bi-directional text. 
 
• Support for Managed Extensibility Framework. 
 
• Enhanced data binding support. 
 
• Enhanced animation effects. 
 
• Clipboard and drag and drop support. 
 
• Deep Zoom performance enhancements. 
 
• WCF Rich Internet Application (RIA) Services. 
 
• Content protection for H.264, and support for playing offline DRM protected media.
Silverlight is a cross-browser, cross-platform plug-in for delivering the next generation of media experiences and rich interactive applications (RIAs) for the Web. Examples include: 
 
For ASP.NET-based Web applications, Silverlight provides a rich UI front-end that, with a consistent programming model, adds support for richer interactivity, media, and audio. 
 
For Microsoft SharePoint–based content, Silverlight offers the ability to create rich Web Parts. 
 
For Windows Live services, Silverlight offers the ability to consume services and APIs more effectively. 
Microsoft designed Silverlight with the ability to deliver high-fidelity experiences on the broadest set of system configurations. Some features, such as HD video, may benefit from the power contained in newer personal computers. 
Some high-end Windows specific features of WPF, such as real 3D, hardware-based video acceleration, and full document support, will not be supported in Silverlight. This is by design in order to serve Silverlight’s cross-browser, cross-platform reach scenario that demands a light weight plug-in. That being said, Silverlight will offer a uniform runtime that can render identical experiences across browsers on both Mac OS and Windows. 
Top 10 features that every developer or individual will love the most in Silverlight 5 :
 
All new controls : Silverlight 5 brings new controls, including Pivot Viewer for the developers, which can easily deal with and manage large amount of data at a given point of time. One of the major benefits of this control is that it enables the end users to easily search the information required from the source collection.
 
Enhanced DialogBox : Before Silverlight 5, the developers were using openFileDialog and SaveFileDialog classes to open and save the file of any extension in the local disk. However, Silverlight 5 has improved DialogBox by introducing new property called “InitialDictionary”, which allows the developers to specify a default path. Also, by using DefaultFileName property in SaveFileDialog, the developers can specify a default file name that gets created whenever the user wants to save data locally from the application.
 
Digital Rights Management : Silverlight 5 brings great support for Live TV scenarios having policies and licenses. It is the responsibility of the Silverlight 5 client to enforce change of the policies for the developers, which means there won’t be any special client application code needed!
 
All new 3-D Graphics support : This is one of the major highlights of Silverlight 5. It has introduced support for using hardware accelerated 3D graphics within a Silverlight application. This has opened new doors of opportunities for the developers to include various things like 3-D drawn controls, data visualizers, 3-D charts, scatter points, 3-D games and more.
 
Adaptive Streaming and On-Demand Media through IIS Smooth Streaming : IIS Smooth Streaming is another great feature in Silverlight 5, which helps the users to bring high definition streams playing seamlessly on any device running Silverlight through standard HTTP protocols.
 
High Resolution Images and Frame Rates via Deep Zoom : It is one of the fastest zooming technologies ever introduced over the web. It will enable high resolution images and frame rates at the lowest loading time for the end users. It opens up the new doors of opportunities for the designers and developers to showcase thousands of items simultaneously on the go!
 
Improved Performance : One of the major features in Silverlight 5 is its enhanced performance. Now all the Silverlight 5 applications will support for 64-bit browsers. Also, they have made certain enhancements in the XAML parser. There are lots of other enhancements made that will help Silverlight applications load faster.
 
Simplified Skinning and Creating Graphics : Skinning and Styling were one of the major headaches for designers, which has been simplified by Silverlight 5. It enables designers to create graphics and then bind them with the customize controls.
 
Text-based Improvements : Silverlight 5 also brought tons of enhancements in character spacing and interline spacing to bring text clarity. It also includes a new control called RichTextBlock to enable the users display rich contents.
 
Trust-based Improvements  : In terms of trusted applications, Silverlight 5 has included various improvements like access to the file system, multiple windows, ability to run inside the browser and call windows APIs.
 
Apart from all these, the users can leverage from enhanced media format extensibility, pixel shader and tons of other features. However, the 10 features discussed in this post are the major highlights of Silverlight 5.

Source : Microsoft Silverlight