Click here to Skip to main content
15,867,308 members
Articles / Web Development / HTML

15 Things I've Discovered about Silverlight

Rate me:
Please Sign up or sign in to vote.
4.88/5 (37 votes)
6 Jan 2011CPOL4 min read 50.9K   46   13
Here is a list of 15 things I've discovered about Silverlight

I love Silverlight and have written / talked about it a lot. I can't help but notice that a lot of people are new to Silverlight or may have played with it a few times. Well, this post is for you. It is a list of 15 things that I've discovered since I started developing for Silverlight. If you are a full-time Silverlight developer, then I would hope you know most of these. I promise not to scare off anyone with talks of MVVM, Prism or MEF.

  1. The line highlighted below represents the MIME type and it is not the runtime version of Silverlight. Many developers are at first confused about this because they think it is referring to the Silverlight version (example: Silverlight 4).

    HTML/ASPX markup of a Silverlight Hosted Application

    image

  2. You can't use .GIF images with Silverlight. Use .PNG files if you need images in a Silverlight application. If you must use .gifs, then you should consider using the .NET Image Tools Library for Silverlight. Many people are also building web services that will convert the .gif files to .PNG. I would recommend converting the images to .PNG with a tool like Paint.NET.

    image61

  3. If a user does not have the Silverlight 4 plug-in installed, users are prompted to download it by the following line of code (found inside the .ASPX or HTML file):

    image_thumb51

    If you change the link to:

    HTML
    <a href="http://go.microsoft.com/fwlink/?LinkID=149156" 
    	style="text-decoration: none;">
        <img src="http://go.microsoft.com/fwlink/?LinkID=161376" 
    	alt="Get Microsoft Silverlight" style="border-style: none"/>
    </a>

    Then it will always download the latest version of the Silverlight runtime. New versions are backward compatible with old versions of the runtime.

  4. All data access in Silverlight is asynchronous. The example below will not work:
    C#
    MyOldWebService srv = new MyOldWebService();
    string strReturn = srv.GetSomeValue();
    txtValue.Text = strReturn;

    This is how we would call a WCF service in Silverlight (for example, after the InitializeComponent method):

    C#
    public MainPage()
    {
        InitializeComponent();
        Service1Client client = new Service1Client();
        client.DoWorkCompleted += new EventHandler<DoWorkCompletedEventArgs>
    			(client_DoWorkCompleted);
        client.DoWorkAsync();
    }
    
    void client_DoWorkCompleted(object sender, DoWorkCompletedEventArgs e)
    {
        MessageBox.Show(e.Result);
    }
  5. Use templates / themes whenever necessary. Microsoft has provided 4 themes that will give your application a custom look. You can also use the built-in Navigation template included in VS2010 or the ones included in Blend 4 (which includes MVVM template). In other words, don't start a project completely from scratch unless you need too.

    image8

    image9

  6. Spend the time to learn Blend 4. Sure you can write all of your XAML (markup) from hand but why? Blend 4 was created to assist with creating applications for Silverlight, WPF and Windows Phone 7. I cannot imagine creating Storyboards and animations by hand. It has a learning curve but it is worth it in the end.

    image13

  7. Make use of the Silverlight Toolkit available on CodePlex.

    The Silverlight Toolkit is a collection of Silverlight controls, components and utilities made available outside the normal Silverlight release cycle. A product of the Microsoft Silverlight product team, the Silverlight Toolkit adds new functionality quickly for designers and developers, and provides the community an efficient way to help shape product development by contributing ideas and bug reports. It includes full open source code, unit tests, samples and documentation for over 26 new controls covering charting, styling, layout, and user input. – Taken from the codeplex site.

    image_thumb24

  8. Be aware that your Silverlight code can be viewed by anyone using tools like Silverlight Spy/.NET Reflector. If your application is on the internet and not an internal application, then you better obfuscate it. It's better to have some security than none. This also works the other way around and you can see how someone built a Silverlight application.

    image17

  9. The .XAP file that your Silverlight project creates is simply a .zip file with a different extension. You can use an external program like 7zip to squeeze a smaller file size than the one included with VS2010. It also pays to open up a .XAP file and examine what's included with your project.

    image25

  10. If a file is not necessary for every user, then do not include it in the .XAP file. I've heard every argument against this saying,” bandwidth is cheap.” However, this method really gets expensive when it's more than 50-100 images or other binaries. I only include the files absolutely necessary for every user of my application.
  11. You can host a Silverlight application in other servers. You do not have to use IIS. Simply setup the MIME type on your WebServer and the Silverlight application will work on the client as long as the Silverlight run-time is installed.

    image26

  12. The community rocks for Silverlight. There are a lot of ways to learn more about it. I'd start with the official Silverlight site, then check out the official forums. I'd also visit Silverlight Cream and Alvin’s Ashcraft’s Morning Dew daily. To finish up, I'd watch every episode of John Papa’s Silverlight TV.

    image30

  13. Once you learn XAML (the markup for Silverlight), you can use those skills to produce applications for the following platforms: Silverlight (duh), WPF, Windows Phone 7, Lightswitch and Surface.

    image

  14. Silverlight works with all the major browsers (Google Chrome 6, Internet Explorer, Firefox and Safari) and Operating Systems (such as Windows and Mac OS). It even includes support for Linux through the Moonlight project.

    image56

  15. Users get the same experience no matter what browser they are running. Remember when one webpage worked fine in Firefox, but not in Internet Explorer 6. Since Silverlight is a plug-in, everyone gets the same experience.

    “SAME EXPERIENCE EVERYWHERE”

Thank you for reading my blog post, as always feel free to subscribe to my feed or add me to twitter.

alt Subscribe to my feed

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Telerik
United States United States
Michael Crump is a Silverlight MVP and MCPD that has been involved with computers in one way or another for as long as he can remember, but started professionally in 2002. After spending years working as a systems administrator/tech support analyst, Michael branched out and started developing internal utilities that automated repetitive tasks and freed up full-time employees. From there, he was offered a job working at McKesson corporation and has been working with some form of .NET and VB/C# since 2003.

He has worked at Fortune 500 companies where he gained experience in embedded systems design and software development to systems administration and database programming, and everything in between.

His primary focus right now is developing healthcare software solutions using Microsoft .NET technologies. He prefers building infrastructure components, reusable shared libraries and helping companies define, develop and automate process standards and guidelines.

You can read his blog at: MichaelCrump.net or follow him on Twitter at @mbcrump.

Comments and Discussions

 
GeneralMy vote of 5 Pin
walterhevedeich22-Sep-11 19:31
professionalwalterhevedeich22-Sep-11 19:31 
GeneralMy vote of 5 Pin
jcBrasil8-Apr-11 7:05
jcBrasil8-Apr-11 7:05 
GeneralMy vote of 5 Pin
Wendelius18-Feb-11 21:16
mentorWendelius18-Feb-11 21:16 
Generalthanks for sharing - have 5 Pin
Pranay Rana5-Jan-11 22:48
professionalPranay Rana5-Jan-11 22:48 
GeneralMy vote of 5 Pin
Abhijit Jana5-Dec-10 6:31
professionalAbhijit Jana5-Dec-10 6:31 
GeneralGood info Pin
Vimalsoft(Pty) Ltd5-Dec-10 2:06
professionalVimalsoft(Pty) Ltd5-Dec-10 2:06 
GeneralMy vote of 5 Pin
Vimalsoft(Pty) Ltd5-Dec-10 2:05
professionalVimalsoft(Pty) Ltd5-Dec-10 2:05 
GeneralMy vote of 4 Pin
OmarAlAmoudi29-Nov-10 2:13
professionalOmarAlAmoudi29-Nov-10 2:13 
GeneralThanks Pin
OmarAlAmoudi29-Nov-10 2:13
professionalOmarAlAmoudi29-Nov-10 2:13 
GeneralMy vote of 5 Pin
Anurag Gandhi28-Nov-10 18:23
professionalAnurag Gandhi28-Nov-10 18:23 
GeneralMy vote of 5 Pin
defwebserver22-Nov-10 17:38
defwebserver22-Nov-10 17:38 
GeneralMy vote of 5 Pin
Kunal Chowdhury «IN»22-Nov-10 16:50
professionalKunal Chowdhury «IN»22-Nov-10 16:50 
GeneralMy vote of 5 Pin
AspDotNetDev22-Nov-10 7:34
protectorAspDotNetDev22-Nov-10 7:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.