As I spend increasing amounts of time writing increasingly complex Silverlight apps, I find that using the full references for objects can quickly become tedious to type in - sender.findName(”productPanel”)["Canvas.Left"], etc. I started using global variables that are assigned on canvas load to make the references less of a hassle. Given the example above, the code might look something like this:

var main;
var panel;

function canvasLoaded(sender){
main = sender.findName(”rootCanvas”);
panel = sender.findName(”productPanel”);
}

Now when I need references elsewhere in the code, something like sender.findName(”productPanel”)["Canvas.Left"] simply becomes panel["Canvas.Left"]. It also means that I don’t need to pass the sender into every function that I write (not that it takes up THAT much space, but it’s less clutter in the code). So a function to display the width of the root canvas might look like this:

function displayWidth(){
alert(main.width);
}

I feel like it makes the code a little easier for me to read - you get the object name and the property in one short description.