First Silverlight 2 Application: Color Picker Silverlight vs Flash: Flickr Image Gallery
Oct 18

Today, I try to upgrade my first sample in this blog to Silverlight 2. Out of my expectation, the code work perfectly and actually I can run the application directly after copy and paste the files.

Anyway, there are some interesting findings when updating the code. I will try to list them all during the upgrade.

Comparison

What’s the difference?

  • DispatcherTimer vs CompositionTarget.Rendering

Source codes

Silverlight

DispatcherTimer vs CompositionTarget.Rendering

In Silverlight 2, it’s much simpler to simulate the  enter frame event by using CompositionTarget.Rednering. It enables you to modify the frame rate easily as well.

// C#
// New Method
Application.Current.Host.Settings.MaxFrameRate = fps;
CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);

void CompositionTarget_Rendering(object sender, EventArgs e)
{
	// do your stuff here
}

// Old Method
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 0, 0, 1000/fps);
timer.Tick +=new EventHandler(_timer_Tick);
timer.Start();

void  timer_Tick(object sender, EventArgs e)
{
	// do your stuff here
}

Shares and Enjoy~

Did you like this post?

Subscribe here:  

8 Responses to “Silverlight 2 Upgrade: 3D Text Space”

  1. contrapunctus Says:

    i still see the install silverlight banner:)

  2. Vojtěch Vít Says:

    Hi, please, update your SL vs Flash gallery Silvelight examples to version 2.0 RTM..:-) Thanks

  3. admin Says:

    Yup, I target to update them all by the end of this month.

  4. Mohammad Sharifi Says:

    WOW
    Please Tutorial for Silverlight 2 ……in here ;-)
    Thank you
    http://www.deva.ir

  5. Silverlight Cream for October 18, 2008 -- #399 Says:

    [...] 2. Jeff Paries reports his Project Updates for Silverlight 2, as does Terence Tsang with his Silverlight 2 Upgrade: 3D Text Space. Martin Grason has been Silverlight 2 busy with Silverlight 2 RTW, the Patient Journey [...]

  6. Evil-minded Angel Says:

    Thanks for you public code and share idea to create 3d text space. I try to download your source code and try to run this application but i found some error about “compositiontarget”.

    The error message is “The name ‘CompositionTarget’ does not exist in the current context”. Please help me to find out or find the best solution to solve this problem.

    For another way, i try to go to bin folder on directly path of this application and click on the testpage.html. The page will be open and alway show silverlight link to download Silverlight 2 Beta 2 v.2.0.31005.1 .

    Surely, i already get and install them into my PC. and i try to click on TestPage.html again and again. That’s link alway show to download.

    Please help me!!

  7. 3D Text Space | Silverlike - A Free Microsoft Silverlight 3 Directory Says:

    [...] very impressive sample shared in Shine Draw. Texts are dynamically generated and flying in a 3D environment. You can move forward of the screen [...]

  8. Resolution App Resolved « The daydreaming Crocus Says:

    [...] movement algorithm I used in my app is based on Terence Tsang’s – aka ShineDraw – 3D Text Space program. Shinedraw’s web site is a true source of inspiration; you can find various Flash vs [...]

Leave a Reply