Silverlight 2.0: Project template for self-resizing applications (update)

An observant reader gave me a better way to automatically resize a Silverlight application. The way I published in my last post was inspired from Silverlight 1.0, where JavaScript is obviously needed to do the job. However, in 2.0, you can register for a CLR event and avoid the multiple conversions between JavaScript and C#. These conversions take time and it's better to avoid them when possible. I modified the Project Template accordingly. You can download the updated version here, and follow the installation procedure here.

The resizing operation is simpler now, since everything occurs in C#. It is as simple as registering for the BrowserHost.Resize event. This event is raised automatically when the application starts up, so no need to call it explicitly. In the event handler, simply calculate the factor (based on the initial dimensions) with which the ScaleTransform must be applied.

The template also takes care of centering the application horizontally, and of registering the main Canvas with the browser host, so that public Scriptable methods can be called from JavaScript. Like in the previous version, you can also pass the page's URL and other parameters to construct the Silverlight application, in order to make it easier to place the same application on multiple web pages.

Print | posted on Wednesday, December 26, 2007 8:38 AM

Feedback

# re: Silverlight 2.0: Project template for self-resizing applications (update)

left by Kuan at 12/27/2007 3:42 AM Gravatar
I'll exactly develop with the self-resizing application! Thanks!

# re: Silverlight 2.0: Project template for self-resizing applications (update)

left by vithoba at 4/9/2008 9:40 AM Gravatar
i need this
Title  
Name
Email (never displayed)
Url
Comments   
Please add 5 and 2 and type the answer here: