Click here to Skip to main content
Click here to Skip to main content

15 Things I've discovered about Silverlight

, 6 Jan 2011
Rate this:
Please Sign up or sign in to vote.
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 :

    <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:
    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):

    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 a 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 Wiindows 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)

About the Author

mbcrump
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.
Follow on   Twitter

Comments and Discussions

 
Generalthanks for sharing - have 5 PinmemberPranay Rana5-Jan-11 22:48 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 6 Jan 2011
Article Copyright 2010 by mbcrump
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid