views:

178

answers:

3

I've got a single Silverlight app that I'd like to display in a grid. The way the Silverlight app displays its content is dependent on the unique ID of the record in each grid row. Unfortunately, the XAP file is re-downloaded for each row in the grid. With a size of 700KB, this really impacts performance. Is it possible to download the XAP file once and then just re-use it for each row in the grid?

A: 

I'm not sure you can. Theoretically it should be cached, but in this case theory don't seem worth squat.

It's all down to the way the < object > tag behaves with it's various params and this is (another) one of the "sparsely" documented areas of silverlight.

Graeme Bradbury
A: 

It is possible but not easy to do. You could download the xap and save it to IsolatedStorage and create a silverlight host each time you need one referencing your cached xap but you only have 1MB space available and you aren't guaranteed that if you have other silverlight apps from the same domain.

Given what you described I still don't see any value in doing what you want to do. I think you have it backwards.

Robert Kozak
I'm using adding a SL data visualization control inside a 3rd-party grid control. The SL GridView is simply less mature and doesn't have all of the functionality of the HTML control I am using. I'm sure this will change over time, at which point your suggestion does indeed make more sense.
Kevin Babcock
Also take another look at your main XAP. Why is it 700mb? Can you factor out images? extra assemblies, etc not needed for this grid you are using.. that way if you need to reuse it many times it will be faster and easier to save.
Robert Kozak
+1  A: 

Once a XAP is downloaded Silverlight will cache the assemblies etc locally per instance of a Silverlight control. If you create another instance of a Silverlight control then this in turn has it's own domain that it in turn looks after.

My suggestion is to abstract out the parts you requrie and bake them into a seperate xaml, then load them into areas where you need them the most. If you still require a central .xap to handle the marshalling / event management etc then in Silverlight 3 we've put in place a Local Connection API which allows other Silverlight instances to talk to one another within the one browser page locally (ie SilverlighA can talk to SilverlightB all within index.html)

This can then allow you to establish a sort of local proxy if you will.

Scott Barnes / Rich Platforms Product Manager / Microsoft.

Scott Barnes
Thanks for the explanation!
Kevin Babcock