Home Interview Questions and Answers Silverlight Interview Questions and Answers Part-2

silverlight11. Quote:Why is XAP important?
Tools, such as Visual Studio 2008 with the Microsoft Silverlight Tools Beta 2 for Visual Studio 2008, 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.

12. Quote:How does XAP work?
Once you have created the .xap file (explained below), the Silverlight 2 plug-in downloads the file and runs it in a separate work space.

13. Quote:How do I use a .xap file?
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.
14. 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.

16. What is the parent xaml tag of Silverlight page?
UserControl is the parent xaml tag of the Silverlight page. All other tags are placed under UserControl tag.
Code:
<UserControl x:Class=”SilverlightApplication2.MainPage”
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation

xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Width=”400″ Height=”300″><Grid x:Name=”LayoutRoot” Background=”White”></Grid></UserControl>

17. 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.
Code:
private void Application_Startup(object sender, StartupEventArgs e)
{this.RootVisual = new YourPage();}

18. 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)

Is ADO.NET objects supported in Silverlight Project?

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 we add normal project reference (normal class library) to the Silverlight project?
NOTE: This is objective type question, Please click question title for correct answer.

How can style elements be applied? (similar to a CSS file/skins)

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>

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.

Extensible Application Markup Language (XAML, pronounced zammel [‘zæm??]) 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 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 Sivlerlight 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)

19. 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.

private void Application_Startup(object sender, StartupEventArgs e)

{

this.RootVisual = new YourPage();

}

20. What is the parent xaml tag of Silverlight page?
UserControl is the parent xaml tag of the Silverlight page. All other tags are placed under UserControl tag.

<UserControl x:Class=”SilverlightApplication2.MainPage”

xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”

xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”

Width=”400″ Height=”300″>

<Grid x:Name=”LayoutRoot” Background=”White”>

</Grid>

</UserControl>

You may also like

Leave a Comment