Explain Silverlight architecture.
Silver light is a plug-in used for different platforms and
browsers. It is designed for offering media experiences based on .net platform.
Silver light offers a programming environment that is highly adaptable, and
offers support for Ajax, Ruby, and Python etc. It can well be integrated with
the web applications which are already exist.
Designers can work together to create high end silver light
tools for the web using Visual Studio along with Expression Studio. To enable
the users to get high level satisfaction from the tools they use, Microsoft has
been emphasized UX, user experience. UX is the collection of the interactive
points for the user.
The Silverlight architecture has three vital components. They
are described below.
1. Core Presentation Framework: This
framework includes the components, services pertaining to UI including input,
light weight UI controls for use with a web application, media playback, data
binding, vector graphics, text, animation, images for presenting various
features. It includes Extensible Application Markup Language for layout
specification.
2. .NET Framework for Silverlilght: Being a
sub set of .NET framework, it contains the components and libraries. Data
integration, extensible windows controls, networking, base class libraries,
garbage collection, and Common Language Runtime are also included. When
Silverlight Libraries are utilized in applications, all the libraries are
packed with the application and downloaded to the browser. The libraries
include new UI controls, XLINQ, Syndication (RSS/Atom), XML serialization, and
Dynamic Language Runtime (DLR).
3. Installer and Updater: It is a control
for simplifying the installation process for the first-time users. And
subsequently provides automatic updates.
Difference between WPF and Silverlight
In terms of features and functionality, Silver light is a sub
set of Windows Presentation Foundation.
Silver light is for developing rich internet applications.
While WPF is used for developing enhanced graphics applications for desktop
platform.
WPF uses XAML for hosting the user interface for web
applications.
What are the limitations of using external fonts in
Silverlight?
One of the major challenges is to use a downloader and some
of the SetFontSource methods on a TextBlock to perform it.
Using SilverLight 2, TextBlock can be used as follows:
<TextBlock x:Name="Header" FontFamily="timheuer.ttf#Tim
Heuer Normal" />
<TextBlock x:Name="ItemText" FontFamily="timheuer.ttf#Tim Heuer Normal"
/>
Describe how to perform Event handling in silver light
Event handling is performed in two event cases – Input events
and Non-input events.
Input Events: The hosting browser for Silver
Light plug-in handles the input events input stimulus, as SilverLight works
within the hosting browser plug-in architecture. The event is sent to
SilverLight plug-in through the browser. Later the event is raised in the
SilverLight Object Model.
Non-Input Events: These events report a
change state of a particular object. For instance, progress of initiated
actions by the web client. Certain non-input events provide information of
objects as a framework level for lifetime. An example of such event is
FreameworkElementLoaded event.
Explain how to add the reference of a Class library project
in Silverlight application project
The following is the process for adding the reference library
project:
After defining business object classes in another project –
Right click on the SilverLight project root
Choose Add->Existing Item
Navigate through the source code file and select it
Click on the arrow (little) towards the right of the Add
button. Later select Add as link.
Repeat the process for adding all files to your SilverLight
project.
What is Silverlight.js file? Explain with an example.
Silverlight.js file is a Java Script helper file. It supports
for adding a Silverlight application to a web page through Java Script. It has
a number of methods defined to help with, most importantly the createObject and
createObjectEx. The following are certain notable functions and event handlers
:
-getSilverlight, isBrowserRestartRequired, isInstalled,
onGetSilverlight, onSilverlightInstalled, WaitForInstallCompletion.
The Silverlight.js file is installed along with Silverlight 2
SDK.
Using Visual Studio 2008, one can create a quick sample
project by selecting File->New Project and selecting Silverlight
Application. After clicking OK, select “Automatically generate a test page to
host Silverlight at build time”. Click on OK. Right click on the new project
and add an HTML page.
Copy the Silverlight.js into local project directory. Define
a reference to Silverlight.js like any other Java Script file:
<script type="text/javascript"
src="Silverlight.js"></script>
Select createObject or createObjectEx, for creating Silverlight object. Add the
following for creating createObjectEx:
// createObjectEx, takes a single parameter of all
createObject parameters enclosed in {}
Silverlight.createObjectEx = function(params)
{
var parameters = params;
var html =
Silverlight.createObject(parameters.source, parameters.parentElement,
parameters.id, parameters.properties, parameters.events,
parameters.initParams, parameters.context);
if (parameters.parentElement == null)
{
return html;
}
}
What is a .xap file? Explain with an example.
A .xap file is an application package based on Silverlight
which will be generated when the Silverlight project is built. This file
helpful in creating heavily client based Silverlight applications. A managed
code can be used such as C# or VB and benefited by utilizing the tools.
A .xap file has an application manifest file
(AppManifest.xaml) and the necessary DLL’s needed by the application. A
manifest file looks like:
<Deployment xmlns="http:// "….”
xmlns:x="http://......"
EntryPointAssembly="SilverlightApplication1"
EntryPointType="SilverlightApplication1.App" RuntimeVersion="2.0.30226.2">
<Deployment.Parts>
<AssemblyPart
x:Name="SilverlightApplication1" Source="SilverlightApplication1.dll" />
</Deployment.Parts>
</Deployment>
The <Deployment> node describes the application and it
contains child AssemblyPart nodes. The DLLs are contained in .xap file. The
EntryPointAssembly attribute describes the selected assembly defined below is
the main assembly for the application. And EntryPointType attribute describes
the class that contains within the assembly that is defined in the
EntryPointAssembly attribute. This is the class which is instantiated to
commence the application.
Explain how can Silverlight use ASX files.
An ASX file is an XML file in which media files are specified
in the playlist. Using ASX files in silver is pretty simple. Assign the ‘
source’ property of a MediaElement object to the ASX file name.
The following is an example of ASX file.
<ASX version = "3.0">
<TITLE>MyFirst ASX Application</TITLE>
<ENTRY>
<TITLE>MyVideo</TITLE>
<AUTHOR>MyName</AUTHOR>
<COPYRIGHT>(c)2010 A company name</COPYRIGHT>
<REF HREF = "xbox.wmv" />
</ENTRY>
</ASX>
Later this .asx file need to assigned to the ‘Source’ property of MediaElement
in XAML file.
<MediaElement
.
.
Source=”myasxfile.asx”
.
</MediaElement>
Finally, add event handlers for supporting the MediaElement.
The following functions are used for stopping, pausing and playing events on
CurrentStateChanged event.
function media_stop(sender, args)
{
sender.findName("MediaPlayer").stop();
}
function media_pause(sender, args)
{
sender.findName("MediaPlayer").pause();
}
function media_begin(sender, args)
{
player =
sender.findName("MediaPlayer");
player.play();
}
function media_state_changed(sender, args)
{
// Obtain the text block for displaying
the status
var mediaStateTextBlock =
sender.findName("mediaStateTextBlock");
// Obtain the media state object
var media = sender.findName("MediaPlayer");
mediaStateTextBlock.Text = media.CurrentState;
}
Explain Silverlight application life-cycle
The entry point of Silverlight applications is Silverlight
Application class. It provides various services which is commonly needed by
Silverlight application.
Silverlight lifecycle commences with opening a web page for
hosting Silverlight plug-in. If the plug-in is not available, the web page
prompts to install Silverlight browser plug-in. Later the browser activates the
plug-in and starts downloading application package. This plug-in loads the
Silverlight Common Language Runntime by which application domain for
application is created.
Later, CLR creates an object of Application class followed by
raising the Application Startup Event. There will be only one Application
instance in any Silverlight-based application. Upon starting up the application
instance provides several commonly used services by the application.
What is the role of Silverlight Plugin in the Silverlight
Application Life-Cycle?
The Silverlight plug-in loads the core services of
Silverlight followed by Silverlight Common Language Runtime. CLR creates
domains for applications. The plug-in enables Silverlight for delivering
cross-platform and cross-browser applications as a subset of the .NET framework
and Windows Presentation Foundation. The plug-in loads the core services of
Silverlight that creates application domains.
Explain the purpose of Storyboard.TargetProperty.
Using Storyboard.TargetProperty, the properties of an object
can be assigned with values. The objects are referred by Storyboard.TargetName
attribute. The following snippet illustrates the change of width and color of a
rectangle object.
<Storyboard>
<DoubleAnimation Storyboard.TargetName="MyRectangle"
Storyboard.TargetProperty="Width" From="150" To="275" Duration="0:0:2" />
<ColorAnimation Storyboard.TargetName="MySolidColorBrush"
Storyboard.TargetProperty="Color" From="Green" To="Red" Duration="0:0:2" />
</Storyboard>
Why is XAP important?
Using XAP, Silverlight applications which are heavily client
based can be created by managing code. The managed code, benefits of using the
tools such as Visual Studio 2008 with Silverlight Tools Beta version 2 , are
utilized by using XAP.
How does XAP work?
The .xap file is used for transferring and containing the
assemblies and resources of an application with managed code. This code must be
written within the Silverlight browser plugin.
Once the .xap file is created, the Silverlight 2 plug-in will
download the file and executes in a separate work space.
Explain the use of ClientBin folder in Silverlight.
The ClientBin folder is used for placing .xap file of a
Silverlight application. This folder can be kept anywhere in the web
application.
What is Clipping in Silverlight?
Clipping is a modification to a given image / object based on
the geometry type – like a line, rectangle, ellipse or even a group geometry
objects. The clip property is defined in the UIElement class. An XAML code is
used for an Image object for displaying a geometrical image. The following is
the code snippet for setting the Ellipse properties.
<Image Source="Nature.jpg" Width="350" Height="350">
<Image.Clip>
<EllipseGeometry RadiusX="100" RadiusY="100" Center="200,150"/>
</Image.Clip>
</Image>
What is the parent xaml tag of Silverlight page? Explain its
purposes.
The’UserConrol’ is the parent xaml tag of a Silverlight page.
All other tags are authored under UserControl tag. Developers are given a
facility to implement new custom controls and create re-usable user controls.
This makes the use of XAML file easy for composing a control’s UI and easy to
implement.
The following code snippet resembles the UserControl tag.
<UserControl x:Class="SilverlightApplication2.MainPage"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="Green">
</Grid>
</UserControl>
Explain with example how to change the default page of the
Silverlight application.
The RootVisual property of Application_Startup event in
App.xaml file needs to be set to change the default Silverlight application
page. The following code snippet sets the property.
private void Application_Startup(object sender,
StartupEventArgs strtevntarg)
{
this.RootVisual = new
YourPage();
}
How many xaml files are created When you create a new
project in Silverlight through Visual Studio and what are the uses of those
files?
There are two xaml files are created when a new project in
Silverlight is created through Visual Studio.
1. App.xaml – This file is used for
declaring shared resources like style objects, brushes etc and for handling
global application level event. The following are the default events created in
App.xaml.cs file.
Application_Startup
Application_Exit
Application_UnhandledException
ReportErrorToDOM
2. MainPage.xaml or Page.xaml – This file is
the default page of the Silverlight application at the time of silverlight
application’s execution. This is similar to default.aspx page of ast.net
application.
What are the programming language that can be used to write
the backend of the Silverlight application?
Visual Basic or Visual C# can be used for authoring code for
the backend of the Silverlight application. The backend refers the code behind
the files of Silverlight pages.
Explain how to set Silverlight contents width as 100%.
Usually the UserConrol will be spread full screen. The
contents width and height can also be set by using width and height attributes.
To get 100% width of the screen set width=”auto” and height =”auto”.
Can you provide a list of Layout Management Panels and when
you will use them?
The following are the list of Layout Management Panels:
1. Canvas Panel: Simple layouts use canvas panel and when
there is no requirement of resizing the panel. The controls will overlap each
other at the time of resizing the panel.
2. Stack Panel: This panel is used to group the controls in a
stack either horizontally or vertically. The overlapping of controls will not
occur.
3. Grid Panel: Grid Panel is the most flexible layout for
placing controls in multi rows / columns. It resembles an HTML table.
Explain how to apply style elements in a Silverlight
project?
Application resources utilize the style elements for
supporting the forms. The App.xaml file could be used to contain an application
resource XML construct. Each style’s target type is set to the control that
needs the style.
App.xaml:
<Application.Resource>
<Style x:Key="MyBorder" TargetType="Border">
<setter property="width" value="3">
</style>
Page.xaml:
<Border Style="{StaticResource MyBorder}">
...
</Border>
What are the main features and benefits of Silverlight?
The following are the features of SilverLight:
1. Built in CLR engine is available for delivering a super
high performance execution environment for the browser.
2. Includes rich framework of built-in class library for using with
browser-based applications.
3. Supports WPF UI programming model.
4. Provides a managed HTML DOM API which is used for HTML enabled programs of a
browser using .NET technology.
5. Silverlight supports PHP or Linux environment. Hence does not require
ASP.NET.
6. Permits limited access to file system for applications. An OS native file
dialog box can be used for using any file.
The following are the benefits of Silverlight:
1. Supports highest quality videos
2. Supports cross-platform and cross-browser applications
3. Features are available for developers with Visual Studio for developing
applications very quickly.
4. Most inexpensive way for video streaming over internet at the best possible
quality.
5. Supports third party languages such as Ruby, Python, EcmaScript!
6. Supports remote debugging.
7. Provides copy protection.
When would one use Silverlight instead of ASP.NET AJAX?
Silverlight media experiences and Rich Internet Applications
can be enhanced by the existing ASP.NET AJAX applications. Web applications and
ASP.NET AJAX technologies are integrated in Silverlight. They are complementary
technologies. Silverlight can interact with AJAX applications for both
client-side and server-side. Certain examples are applications mapping, video
playback.
When would a customer use Silverlight instead of Windows
Presentation Foundation (WPF)?
Silverlight is used by customers for broader reach of
interactive media content and browser-based rich interactive, high performance
applications.
The features of WPF such as platform, UI, Media, offline communication,
integration of OS, integration of Office, access to peripherals, supporting
documents etc., are integrated into Silverlight.
Does Silverlight have a System.Console class? Why?
Yes. Silverlight have System.Console class. It is cocooned in
the SecurityCritical attribute. It is so for using for internal uses and making
it useless for remote usage.
Is it possible to load external OTF or TTF in Silverlight?
How
It is possible to load external OTF or TTF in Silverlight.
The process is:
Right click on Silverlight application project folder.
Select “Add->New Item…”.
Browse and select the font and click on OK buton
Select the font and set the grid property Build Action =
“Resource”, and “Copy to Output Directory” = “Copy if newer”:
Use the following syntax in the FontFamily attribute of
XAML file
FontFamily=”[FontFileName]#[FontFriendlyName]”
Example: <TextBlock Text="Hello"
FontFamily="Century.ttf#Century"></TextBlock>
To find the exact font name, double click on the font to
open the font viewer.
What are the properties that have to be initialized for
creating a Silverlight control using createSilverlight()?
The properties ‘source’ and ‘elementID’ are to be
initialized. The ‘source’ attribute can be a ‘.xaml’ file or an ‘.aspx’ file.
The elementID can be a string that identifies the file.
Explain what happens (internally) when a user that doesn’t
have the Silverlight runtime accesses a page that uses Silverlight controls.
Explain the Path instructions in XAML
The <Path> instruction of XAML allows to draw and fill
a path. Various points in the path represents are represented by the Data
attribute. The attribute includes M which means to move to command, moves to a
coordinate and C represents the absolute path. The H represents line to
command.
The following is the code snippet to draw a path:
<Path Data="M 200,40 C 50,90 200,250 200,75 H 480"
Stroke="Black" StrokeThickness="4"/>
Explain the resemblance between CSS and Silverlight,
regarding overlapping objects.
Silverlight content is hosted on the tag. CSS of DIV can be
changed as it is for other HTML documents. The changes can be for absolute
positioning, z-indexing, top and left properties etc.
top:14px;">
What kind of Brushed does Silverlight support?
Silverlight brush objects supports for painting with solid
colors, linear gradients, radical gradients and images.
SolidColorBrush is used to paint a closed object such as
rectangle
LinearGradientBrush - used to paint a linear gradient like
glass, water and other smooth surfaces.
RadialGradientBrush – used to paint a radial gradient which
is a blend together along an axis.
Explain the arguments for the addEventListener() method.
The first argument is an action event like mouseDown, mouseUp
etc. The second argument is a call to a function. The following lines
illustrates the use of addEventListener() method.
function myfunction(x) { alert(x) }
Obj.addEventListener(“mouseDown”, myFunction(‘hello’);
Explain the mouse events that Silverlight currently
supports.
The mouse events that supports silverlight are
LostMouseCapture - occurs when an UI element lost mouse
capture
MouseMove - occurs when the mouse position changes
MouseEnter - occurs when the mouse pointer enters into the bounding area of an
object
MouseLeave - occurs when the mouse pointer leaves the bounding area of an
object
MouseLeftButtonDown - occurs when the left mouse button is down
MouseLeftButtonU - occurs when the left mouse button is up followed by
MouseLeftButtonDown
Difference between MouseLeftButtonDown and MouseLeftButtonUp
in Silverlight.
The difference is the action of the button. Once mouse button
is pressed MouseLeftButtonDown event is invoked and MouseLeftButtonUp event is
invoked after pressing left mouse button down and release it.
What is the function used for removing an event listener?
The method removeEventListener() is used for deleting an
event listener. The parameters for this method are eventName and listener.
How would you implement Drag-and-drop in Silverlight?
Drag and drop in Silverlight can be implemented by using Drag
Drop Manager by using DragSource and DropTarget controls. DragSource makes any
control to be draggable and DropTarget defines a location in the application to
drop the DragSources.
What are the properties of the eventArgs argument when
capturing keyboard events?
The properties of eventArgs are types of keys like shift,
ctrl and mouse actions, mouse pointer coordinates, x coordinate value, y
coordinate value
What is the function used to get a reference to an object
inside the Silverlight control?
What objects support tranformations? What are the transformations that
Silverlight supports for the elements?
Explain the steps needed to be performed in order to create an animation in
XAML
What are the animation types supported by Silverlight?
Explain the concept of KeyFrame. What is the difference between Silverlight and
Flash regarding animations?
Explain how to control animation from JavaScript code.
How could you determine the media position when playing a video in Silverlight?
Explain the ways of accessing the Silverlight control from JavaScript?
What are the three units of information that the Silverlight plug-in exposes to
JavaScript?
How could you modify XAML content from JavaScript?
What are the necessary step that need to be performed in order to download
content from within Silverlight?
What ASP.NET control can embed XAML into ASP.NET pages?
Does Silverlight supports database connectivity? Explain
What is the codec Silverlight supports for HD streaming?
How can IIS improve Silverlight Streaming?
How to create hyperlinks in silverlight(in windows presentation foundation)?
What is SMPTE VC-1?

.gif)
.gif)
.gif)
.gif)
.gif)
.gif)
.gif)
.gif)