Geeks With Blogs
Imran Shaik Silverlight Quintessential Rambling

Silverlight browser integration and browser hosting always surprised me, when I first started with Silverlight I had troubles making my canvas bigger than 640x480 and its only later on I found that its not as easy as it looks and that I have to set Silverlight application size more than once. (xaml, js, html), after few updates on Silverlight templates its possible to do it in just xaml and html, and the reason is that Silverlight 1.1 relying on DOM to host Silverlight applications.

With the announcement of Silverlight 2.0 and the structure of Silverlight 2.0 not relying on JavaScript to initialise and not depending on DOM but instead initialising  as object  solves atleast one problem that I noticed in Silverlight 1.1/Silverlight 1.0.

Problem:

When a browser page hosting a Silverlight application is zoomed in/out with Browser zoom, Silverlight object's width/height will change but there is no Zoom on the Silverlight Page,this due to Silverlight objects dependency on DOM to host and initialise the Silverlight objects.

Example:

I created three different objects, 1 Silverlight, 1 Flash and 1 JPG raster, (All in one html page) all these objects was derived from the same vectors.

Figure 1: Normal View in HTML at 100% zoom.

 2008-02-14_141748

Figure 2: Browser Zoom at 75%

 2008-02-14_141809

Figure 3: Browser Zoom at 50%

2008-02-14_141826

Figure 4: Browser Zoom at 125%

 2008-02-14_141853

Figure 5: Browser Zoom at 150%

2008-02-14_141916 

Reason:

In previous versions of Silverlight (Silverlight 1.0 /Silverlight 1.1) where Silverlight is initialised by JavaScript and is dependant on DOM to hold the Silverlight object, and Silverlight canvas is defined size which is not relative to the DOM because the Height/Width was defined by the DOM Height/Width and Silverlight Canvas separately, this was not issue with Silverlight canvas initialised with Browser Interop height/width because the Canvas dimensions are set by the DOM object,the when Silverlight Objects have to be initialised in defined space along with other objects, this problem persisted. Because of this when a page is zoomed in browser with Browser zoom, the DOM holding the Object will increase but since Silverlight objects dimensions are independent, it won't fill the DOM.

Solution:

The solution was to initialise Silverlight object which is independent of the DOM, this can only archived by creating  Silverlight as an object, with what we have seen in Silverlight 2.0, it doesn't require the DOM to initialise and this will not be an issue with Silverlight 2.0 applications. But this might persist in Silverlight 1.0.

Download Example Source Code 

Posted on Saturday, February 23, 2008 12:56 PM Silverlight | Back to top


Comments on this post: Silverlight 2.0 Initialisation Improvement

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Imran Shaik | Powered by: GeeksWithBlogs.net