HtmlDocument doc = HtmlPage.Document;
Here, the GetNecessaryHeight() calculates the hight based on the current number of rows in the grid. The code above is executed on the DataLoaded event for the grid.
I've ran into a problem with this approach on the accordion panels other than the first one - the resizing would reload the Silverlight control if it isn't in the first panel. This was easily fixed by placing the <object...> element inside of a AJAX UpdatePanel.