Writing Your First Windows Sidebar Gadget

October 22nd 2006 Sidebar Gadgets JavaScript Windows

This whitepaper should definitely be your first source of information when starting with gadget development. Unfortunately I didn't find it as helpful as it could be. Find below a few issues that could be covered better since I've been struggling with them for some time before I got everything to work as expected.

  • The style definition for body in both pages is missing the unit – px. Without it the definition is invalid and the gadget shows up with minimum size. The correct style definition would be in the likes of:
    body   
    {  
    width: 130px;  
    height: 50px;  
    }
    
  • The settingsUI property is a member of System.Gadget not System.Gadget.Settings. This time the error is in the reference not the whitepaper.
  • If you're only replacing the files in the C:\Users\<username>\AppData\Local\Microsoft\Windows Sidebar\Gadgets directory to update the gadget you might have some problems with caching even if you close all gadget instances as the whitepaper suggests. In my case the old image files and gadget.xml file were still used although they have been replaced. Restarting Windows Sidebar should help.
  • Don't forget that gadget settings are stored with a particular gadget instance. This makes it possible to display two instances of the gadget with different settings. The side effect is that they get lost every time you remove the gadget from the sidebar and put it back on. It works like that by design and if you need persistent common settings for all instances you'll have to use a different solution.
Copyright
Creative Commons License