Silverlight FAQs – Part 1

Where session variables are stored in Silverlight?
In Isolated Storage.

What is the basic object for Animation in Silverlight?
Storyboard.

Why are triggers used in Silverlight?
To fire events.

What is default binding in Silverlight?
Oneway binding.

What are different types of Resources available in Silverlight?
1. Static Resources
2. Dynamic Resources

Are ADO.NET objects supported in Silverlight?
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.

Can you call a JavaScript function from Silverlight?
Yes, JavaScript can be directly called via the HtmlPage.Window.Invoke() function.

Can we add normal project reference (normal class library) to the Silverlight project?
No, we can not use normal projects (class library) reference into Silverlight project. We can only add reference of other Silverlight projects.

However, you can add the reference of a Web Service or WCF services.

Can you provide a list of Layout Management Panels and when you will use them?
Canvas Panel: use a canvas for simple layouts and when there is no need to resize panel. Controls can overlapped each other when resizing the panel.

Stack Panel: use this for grouping controls in a stack (horizontal/vertical). Controls do not overlapped.

Grid Panel: most flexible, multi row/columns layouts. Similar to a HTML table.

How to set Silverlight contents width as 100%?
Generally you can’t set the UserControl width in % like 100% so that the Silverlight contents can spread in the full screen.

To get the 100% width of the screen you can set width=”Auto” and height=”Auto”.

Which language is used to design the layout in Silverlight?
To design the layout of the Silverlight application, XAML language is used.

XAML (Extensible Application Markup Language) is a declarative XML-based language created by Microsoft which is used as a user interface markup language to define UI elements, data binding, eventing, and other features.

Which programming language can be used to write the backend (code behind) of the Silverlight application?
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 Silverlight pages.

When you create a new project in Silverlight through Visual Studio, how many xaml files are created and what are the uses of those files?
When we create a Silverlight application from Visual Studio, two (2) xaml files are created into the Silverlight project.

They are:
1. App.xaml – App.xaml is a file used to declare shared resources like brushes, various style objects etc. and to handle the global application level event (this is almost similar to global.asax file in asp.net application). By default following events are created in the App.xaml.cs file-

Application_Startup
Application_Exit
Application_UnhandledException
ReportErrorToDOM

2. MainPage.xaml or Page.xaml – This page is the default page of the Silverlight application and when the Silverlight application runs this becomes the default page to appear (this page is like the default.aspx page of asp.net application)

How to change the default page of the Silverlight application?
To change the default page of Silverlight application, you need to set the RootVisual property inside the Application_Startup even of App.xaml file-

this.RootVisual = new YourPage();

What is the use of ClientBin folder?
ClientBin folder is used to place the .xap file of Silverlight application. You can keep this anywhere in your web application but this is the default that is used by the Silverlight.

What is XAP file, what does XAP mean, why it is important, how it is used/ consumed?
XAP = dll(s) + AppManifest.xaml
A XAP file is a combination of required DLLs and a AppManifest.xaml file compressed together and ZIP extention is changes to XAP. If you change the XAP extention back to ZIP, extract this ZIP file, then you will find one or more DLLs (depending on any third party assembly or component were used while building the Silverlight application) and one AppManifest.xaml file.

Formally speaking, A .xap file is a Silverlight based application package that is generated when the Silverlight project is built.

XAP (pronounced ZAP) is the file extension for a Silverlight based application package (.xap). This file contains the compressed assemblies and resources of a Silverlight application.

Tools, such as Visual Studio 2010, Expression Blend with the Microsoft Silverlight Tools, allow you to create Silverlight applications that are heavily client based using managed code. You can use managed code, such as C# or Visual Basic, and benefit by using the tools that you are used to working with.

Once you have created the .xap file (explained above), the Silverlight plug-in downloads the file and runs it in a separate work space.

A .xap file is used to contain and transfer the assemblies and resources of a managed code application. This managed code application must be run within the Silverlight 2 browser plug-in.

Visit http://forums.asp.net/t/1277554.aspx for complete details.

What is Silverlight.js file?
Silverlight.js is a helper file which enables Web sites to create advanced Silverlight installation and instantiation experiences.

For more details visit http://code.msdn.microsoft.com/silverlightjs.

What features are missing in Silverlight presentation markup that are supported in WPF (Windows Presentation Foundation)?
Some high-end Windows specific features of WPF, such as real 3D, hardware-based video acceleration, and full document support, are not 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.

What is Application Library Caching?
A way to improve Silverlight application’s performance by allowing third party assemblies to be cached at client. To read more on this and know how to enable this in your Silverlight project, please follow this link.

Can we use Application Library Caching and Out-Of-Browser support in same application?
No

URL Vs URI – What is the Difference?
URL (Uniform Resource Locator) is no longer in use in any technical specifications, and URI (Uniform Resource Identifier) is now preferred. URI has roughly same meaning as URL, but it is more generic because URI does not imply that you are using one of the familiar protocol such as HTTP or FTP which is in the case of URL.

This entry was posted in Interview Questions, Knowledge Sharing, Silverlight. Bookmark the permalink.

Leave a Reply