Silverlight Tip – Initialize!
Wow, who said learning new stuff wasn’t fun! :) Here is another little gem I found which will change your understanding of how Silverlight applications work.
I had a little application that was working great, it even had a bunch of nifty video things taking place in the code behind. I wanted to redo my layout and so cleaned out the old code, built my new layout and then something went wrong.
I just got a blank web page with no errors, compiler error or warnings – just no Silverlight control. I checked and checked and recompiled and cleaned cache and had a beer – still nothing.
So I created a new project and test xaml page and that worked fine – then I looked at the code behind and spotted the issue. The code below is added by default and IS required – I had accidentally removed it when cleaning up, must be getting old ;-)
You must have the following in your code behind page (user control class)
public Page()
{
InitializeComponent();
}
Pretty simple but something you can delete and not notice until nothing works :) Silly me.
Tags: silverlight tips
