Interview patterns - technical interview questions logo
 

Silverlight interview questions

by Alex 2. March 2009 06:49

I have been asked a lot of questions recently on how to quickly evaluate someone’s knowledge of web related technologies. Especially I had a lot of questions about Silverlight experience. So, leaving apart HTML, JavaScript, CSS, AJAX and etc, I wanted to give couple real life examples of simple but useful Silverlight questions.

Hiring Silverlight contractors or full time developers first of all, ask for demos. One demo can tell you more than thousand questions. Ask how particularly each functionality, object, user control were implemented and what were the challenges? Continue with generic question, like why did you choose to do this project in Silverlight, what are the advantages, what are the disadvantage? If the person worked with Flash before, ask what the differences are, which technology is most suitable for which type of projects, etc. This should give you pretty good understanding of one’s overall knowledge about Silverlight.  

Once it’s done it is time for hands-on experience testing and below is the list of my favorite SL questions along with the answers you should be looking for:

What is XAML ?
Extensible Application Markup Language (XAML, pronounced zammel) is a declarative XML-based language created by Microsoft which is used to initialize structured values and objects.
http://en.wikipedia.org/wiki/XAML

What is the difference between WPF and Silverlight?
Silverlight uses a particular implementation of a XAML parser, with that parser being part of the Silverlight core install. In some cases, the parsing behavior differs from the parsing behavior in Windows Presentation Foundation (WPF), which also has a particular implementation.  More information.  

Can you name built-in layout panels you have been using with Silverlight?
You are looking for Canvas, StackPanel and Grid
More information.

What is Storyboard?
Storyboard is a Silverlight class with controls animations with a timeline, and provides object and property targeting information for its child animations
More information.

Given XAML below
<Canvas>
   <Ellipse x:Name="ellipseTest" Height="20" Width="20" Canvas.Left="0" Canvas.Top="10" />
</Canvas>

How can you implement following functionality: clicking left mouse on the ellipse should start ellipse movement to the right, ellipse should stop after moving 200px ?

In the answer you are looking for following steps:

1. Ellipse should have on mouse click event handler: either MouseLeftButtonUp or MouseLeftButtonDown, as following MouseLeftButtonUp=”AnimationStart”

2. Canvas should include Storyboard in the resource section :

Canvas.Resources>
<Storyboard x:Name="sbTest">

</Storyboard>
</Canvas.Resources>

3. Storyboard should contain double animation object:
 <DoubleAnimation Storyboard.TargetProperty="(Canvas.Left)" From="0" To="200" Storyboard.TargetName=”ellipseTest” Duration="0:0:1" />

4. Storyboard.TargetProperty should be set to (Canvas.Left) and Storyboard.TargetName should be set to name of ellipse object i.e. ellipseTest

 Given XAML below 

<Grid x:Name="LayoutRoot" Background="White">
 <Image HorizontalAlignment="Right" x:Name=”img”  Width="100"/>
</Grid>

How can you set image Source dynamically from C# application to” test.png” file?

Surprisingly it is not as straight forward as it might sound, but anyone who seriously worked with Silverlight should be easily answer it.

One of the ways is:  img.Source = new BitmapImage(new Uri("test.png", UriKind.Relative));

Given XAML below


<Canvas>
   < Rectangle x:Name="test" Height="20" Width="20" Canvas.Left="0" Canvas.Top="10" />
</Canvas>

How can you implement following functionality: clicking left mouse on the box should start box movement to the right, but instead of having linear speed object should move rapidly when it begins, slows down, and then speeds up again before it ends.

In this question you are looking for Key-frame animations, particulary SplineDoubleKeyFrame and Bezier interpolation.

To animate with a key-frame animation:

• Add Translate Transform Property to Rectangle object
< Rectangle x:Name="test" Height="20" Width="20" Canvas.Left="0" Canvas.Top="10" >
<Rectangle.RenderTransform>
      <TranslateTransform
        x:Name="saTranslateTransform"
        X="0" Y="0" />
    </Rectangle.RenderTransform>

</ Ellipse>

• Declare the animation and specify its Duration, as you would for a From/To/By animation.
• For each target value, create a key frame of the appropriate type, set its value and KeyTime, and add it to the animation's KeyFrames collection.
• Associate the animation with a property, as you would with a From/To/By animation
• Set KeySpline property to represent accelerate – slow down behaviour

<DoubleAnimationUsingKeyFrames Storyboard.TargetName="saTranslateTransform " Storyboard.TargetProperty="X" Duration="0:0:2""> 
               <SplineDoubleKeyFrame Value="200"  KeyTime="0:0:2" KeySpline=" 0.0,1.0 1.0,0.0 " /> 
</DoubleAnimationUsingKeyFrames>

More Silverlight interview questions:
http://silverlight.megasolutions.net/
http://www.cleartechnicalinterview.com/?p=284

Currently rated 4.9 by 8 people

  • Currently 4.875/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

C# | Silverlight


Comments




All material copyright © North Pacific Technology Group, LLC. All rights are reserved. No part of any material on this web site may be reproduced, or stored in a database or retrieval system, distributed, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission. Terms of use.

Powered by BlogEngine.NET 1.4.5.0

Job Search

what
job title, keywords
where
city, state, zip
jobs by job search