Update: The demo, the source code and the code in the article are compatible with Silverlight 2 RTW. The only changes I made were to the object element in the host page.
This tip is about adjusting the size of the Silverlight object in the Html to the size of the content in our Silverlight application. The example I will use will manipulate only the height, because the width can be manipulated in analogical way.
Let's start with explanation of how we're going to access the Silverlight object in the HTML. We use the HtmlPage object in the codebehind. With its help we invoke a javascript function, which will deal with Silverlight object in the mark up:
private void ResizeSilverlightOnject( double height )
{
HtmlPage.Window.Invoke( "ResizeObject", new object[] { height } );
}