You may like to change the layout and behaviour of your sidebar gadget in docked and floating style. This could be easily done, by handling two events that are fired when docked/undocked.
onDock and onUndock are triggered in the case that a Gadget is moved to the Sidebar or from the Sidebar to the desktop. Use a javascript file that defines the following functions as handlers for those events:
System.Gadget.onUndock = undockedState;
System.Gadget.onDock = dockedState;
Into a function dockedState() you should call System.Gadget.beginTransition() that stops all visuell updates on the gadget on the transition way from docked to floating and vice versa. After that you're able to make all changes to the layout and behaviour a Gadget might have. Before finishing call System.Gadget.endTransition() to resume updates and refresh the Gadget, so that all changes that are done get applied to the Gadget.
function dockedState()
{
System.Gadget.beginTransition();
(..)
System.Gadget.endTransition(System.Gadget.TransitionType.none,0);
}
You can also use the Gadget API to check, in which state the Gadget is with:
if (!System.Gadget.docked)
{
//do something
}
There are several more events and methods in System.Gadget namespace that could be used for different requirements. Use the MSDN Help to discover more options at http://msdn2.microsoft.com/en-us/library/ms723683.aspx