I have a silverlight app that I want to allow size like a regular HTML page. That is, I want the size of the silverlight plugin to expand and shrink in height to accommodate the dynamic data and controls with which I populate the silverlight application. So, let's say I have a page with a grid and a button. The user presses the button and the grid receives a bunch of lines with images making the natural size of the grid higher than the browser window. I would like to have something in place to resize the silverlight plugin to suit the desired mesh size. The following and several other attempts do not work:
void MainGrid_LayoutUpdated(object sender, EventArgs e)
{
HtmlPage.Window.Invoke("setSilverlightSize", this.MainGrid.DesiredSize.Height);
}
<body style="height:100%;margin:0;">
<form id="mainForm" runat="server" style="height:100%;">
<asp:ScriptManager ID="ScriptManager" runat="server"></asp:ScriptManager>
<div id="SilverlightContainer" style="height:100%;">
<asp:Silverlight ID="SLMain" runat="server" Source="~/ClientBin/My.Silverlight.Main.xap" Version="2.0" Width="100%" Height="100%" />
</div>
</form>
<script type="text/javascript">
function setSilverlightSize(val) {
var host = document.getElementById("SilverlightContainer");
host.style.height = val + "px";
}
</script>
</body>
Desired size MainGrid always wants to be the size of the window. Arg told the pirate.
-r