Silverlight vs Flash: Driving Game with hit test Silverlight vs Flash: Double Click
Jan 05

Theming and Styling are the most important element for RIA Technology. Both Flash and Silverlight have provided a wide range of methods in styling the controls and UI.

Today, I will just use a simple example to illustrate how to style the UI in both of the technology. Please also note that the styling will apply to the default UI directly. That means you don’t have to specific class name or style name to the UI.

If you are new to theming, you may encounter some technical problems in using the sample. Please let me know if you need further assistant. (Please read the rest of the articles first!)

Comparison

Flash implementation: 30 minutes
Silverlight implementation: 20 minutes (Implemented First)
What’s the difference?

  • Apply Style: StyleManager [AS3] vs ImplicitStyleManager [C#]

Source codes

Flash

Silverlight

How to Apply Style in Flex: StyleManager [AS3]

The sample above is actually created by Flex since it has a better infrastructure in styling the controls. Usually, the styles will be applied at compile time. However, if you want to apply the style at run time, you have to compile the css file into swf file first. (You may just right click on the css file under Flex Builder and it will prompt up a compile option.)

// AS3

import mx.styles.StyleManager;
import mx.events.StyleEvent;  

// swf can be loaded from remote resources
public function init(e:Event):void {

	var myEvent:IEventDispatcher =  StyleManager.loadStyleDeclarations("./Theme.swf");
	myEvent.addEventListener(StyleEvent.COMPLETE, on_style_completed);
}

private function on_style_completed(event:StyleEvent):void {
	// do something
}

How to Apply Style in Silverlight: ImplicitStyleManager [C#]

For Silverlight, I will now list out the key steps in managing the above sample.

Firstly, download the latest Silverlight Toolkit. It provides you the ImplicitStyleManager Class for styling the UI. Next, open the samples and import the following dll files from the toolkit

  • Microsoft.Windows.Controls.DataVisualization.dll
  • Microsoft.Windows.Controls.dll
  • Microsoft.Windows.Controls.Input.dll
  • Microsoft.Windows.Controls.Theming.dll

You must also include the following assembly in your reference, or you will never find out where the problem is

  • System.Windows.Controls
  • System.Windows.Controls.Data

Where everything is ready, you may drag a sample XAML style file from the toolkit folder \Samples\Source\Controls.Samples\Theming\ThemeBrowser\ShinyBlue.xaml into your project. Remember to change the file type to Content. At the end, use the below code to apply the template.

// C#
// Style must be loaded from the resources
// Loading styles from remote server is not allowed
Uri uri = new Uri("ShinyBlue.xaml", UriKind.Relative);
ImplicitStyleManager.SetResourceDictionaryUri(LayoutRoot, uri);
ImplicitStyleManager.SetApplyMode(LayoutRoot, ImplicitStylesApplyMode.Auto);
ImplicitStyleManager.Apply(LayoutRoot);

Shares and Enjoy~

Did you like this post?

Subscribe here:  

47 Responses to “Flash vs Silverlight: Theming and Styling”

  1. Automotive CRM Guy Says:

    One problem with Silverlight is you can’t change the style property of a control more than once at runtime. It throws a weird exception…

  2. Leio Says:

    how about the design tools~~~~~~~~~~?

  3. admin Says:

    Automotive CRM Guy:
    Ya, you can only apply theme once only.

    Leio:
    I may not talk about the design tool since I am not a good designer! haha

  4. Serge Jespers Says:

    Flex apps can be styled using CSS and that CSS can also be changed on runtime! It doesn’t have to be compiled like you claim in this article. With runtime CSS, Flash is clearly the winner!

  5. Flash vs Silverlight: Theming & Styling at Programming with Silverlight, WPF & .NET Says:

    [...] Deshalb vergleicht Shindraw - Your Flash and Silverlight Repository den Vergleich des Theming and Styling in Silverlight und Flash. [...]

  6. Rick Says:

    Is it just me or do other people also have the problem that the silverlight example is blank?

    I do get the loading thing and it goes to 100% but after that its just blank. Tested it with IE 7 and FireFox 3.

  7. Tek Says:

    Silverlight example is blank for me too. SL 2.0.31005.0

  8. memals Says:

    silverlight example is blank :(

  9. admin Says:

    oh. that’s funny.

    It’s working fine for me. Is there any one can see the sample?

  10. John Says:

    Blank for me too :(

    SL 2.0.31005.0

  11. Mondain Says:

    It would seem that a majority of people who visit this site use IE, hence the score for SL. I use chrome and the SL example is blank, so I certainly cannot vote for SL.

  12. Mike Says:

    I am using Chrome and the SL shows up fine for me.

  13. Fallon Massey Says:

    I asked this question before, but I hope someone will answer it for me.

    Can I compile your Flash version using the open source version of the Flex 3 SDK?

    If not, what do you suggest?

    Thanks.

    P.S. the Silverlight app is all white.

  14. admin Says:

    Fallon, the sample this time is make by Flex and I am sure you can compile with Flex 3 SDK. For previous samples, I didn’t try the to compile with SDK. However, theortically, you can do this as well.

    By the way, the sample I made work for me in IE, Firefox and Safari. I wonder if the client has to install the Silverlight Toolkit or it requires .net framework 3.5 to run it?

    I will check that out.

  15. Fallon Massey Says:

    The client shouldn’t have to have any of those things.

    I just looked at in FireFox, and it’s still all white, which generally means an exception of some sort.

    By the way, I ask about Flash because even though I’ve never developed in Flash, and LOVE Silverlight more, clients want RIA on their websites.

    We don’t have time to wait for the years it’s going to take Silverlight to be useable on the internet. We’ll use Silverlight on intranet applications, but it looks like Flash wins for general applications.

    Customers can’t base their businesses on a technology that nobody has, and generally won’t download.

  16. admin Says:

    Fallon, I agree with you.

    I would rather blame the blank problem to Microsoft.
    How shall I solve the problem when everything working fine for me? haha

  17. Rick Says:

    I dunno if this is the problem because im no developer ;-) but I get a couple of errors when opening the project in expression blend. All the errors are in the Microsoft.Windows.Controls.Theming.ShinyRed.xaml file.

    It says that it cant find the resource file on line 1519 for example. This line contains:
    Style=”{StaticResource System.Windows.Controls.Primitives.ScrollBar}”

    I did add all the necessary .dll files

  18. admin Says:

    Rick, could you please check if you have added the following references?

    System.Windows.Controls
    System.Windows.Controls.Data

  19. Xigmond Says:

    No doubt Flash is the best !
    could someone please tell me where can I find Silverlight’s Platform?
    is there anything like that at all?

    ;)

  20. Rick Says:

    @admin

    I did add those references and when I build I got a blank screen. Next thing I did was delete those 2 references and added the onces that where in the .xap file. This seems to help a bit. Now when i build i can see the controls but after clicking on the button the screen turns blank again.

    Still getting those errors in expression blend:
    The resource “System.Windows.Controls.Primitives.Scrollbar” could not be resolved.

  21. Justin-Josef Angel Says:

    Terrance, Excellent stuff! Thanks for compiling that.

    I’m really happy to see ImplicitStyleManager is growing in popularity.
    I Especially think that there’s a noticeable difference in professional finish between the Microsoft shipped themes with the Flex theme.

    Terrance, keep up this extremely high quality content coming. I love this blog :)

    – Justin
    Microsoft Silverlight Program Manager

  22. Paulo Larini Says:

    It´s a joke, or or its is so silverbright that I could not see it ? :>
    Blah, silverlight is crap.

  23. Flash vs. Silverlight: What Suits Your Needs Best? | How-To | Smashing Magazine Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  24. Flash vs. Silverlight: What Suits Your Needs Best? | Fresh News - Blog Design, Wordpress, Blogger, and Web Development Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  25. Flash vs. Silverlight: What Suits Your Needs Best? | webnhance.com Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  26. abhi Says:

    Dont use chrome it sucks.

  27. Flash vs. Silverlight: What Suits Your Needs Best? | jeremiahnellis.com/design_life Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  28. Flash vs. Silverlight: What Suits Your Needs Best? | i-Technews Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  29. Flash vs. Silverlight: What Suits Your Needs Best? | Best Design Content Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  30. Flash vs. Silverlight: What Suits Your Needs Best? - Best Design Content Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  31. Flash vs. Silverlight: What Suits Your Needs Best? - Carla Aschnikov Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  32. Silverlight « F13 Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  33. Flash vs. Silverlight: What Suits Your Needs Best? | The Scripts Zone Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  34. dykin's me2DAY Says:

    리거니의 생각…

    Flash vs Silverlight: Theming and Styling…

  35. Flash vs. Silverlight: What Suits Your Needs Best? | zbTech.net Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  36. Flash vs. Silverlight: What Suits Your Needs Best? | design shop Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  37. Flash vs. Silverlight: What Suits Your Needs Best? « BeginnerPC : Tips , Tricks & Tutorials Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  38. meshdairy » Flash vs. Silverlight: What Suits Your Needs Best? Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  39. Михаил Кузьмин Says:

    Благодарю. Давно такое искал :)

  40. spam-dev Says:

    good silverlight theme sample.

    spam-dev.

  41. Geek is a Lift-Style. »Archive » Flash vs. Silverlight: What Suits Your Needs Best? Says:

    [...] Flash vs. Silverlight: Theming and Styling [...]

  42. Johnnie Starcevic Says:

    that’s incredible.

  43. Milo Toussant Says:

    Cool, there are truly some very good points on this post most of my readers may find this useful, I’ll post a link, appreciate it.

  44. photo upload php Says:

    Outstanding details for upload files for having myself get started. I will keep this particular website link and revisit it.

  45. 10. {Undeniably|Unquestionably|Definitely} believe that which you {stated|said}. Your favorite {justification|reason} {appeared to be|seemed to be} on the {internet|net|web} the {simplest|easiest} thing to be aware of. I say to you, I {definitely|certainl Says:

    20. I am really impressed with your writing skills as well as with the layout on your weblog. Is this a paid theme or did you customize it yourself? Either way keep up the nice quality writing, it is rare to see a nice blog like this one today..

  46. Sunni Phagan Says:

    Good information, a number of thanks to the author. It’s puzzling to me now, typically, the usefulness as well as significance is overpowering. Vastly thanks again and better of luck!

  47. Alexander Says:

    Your way of describing the whole thing in this post is actually good, every one can easily know it, Thanks a lot.

Leave a Reply