Problem:
The browser scrollbar doesnt appear when the silverlight control grows beyond the size of the page.
Solution:
The first point in finding the solution is realizing that the silverlight control itself resides WITHIN the asp.net control defined on your webpage and that this control's size doesnt change when the silverlight control changes. (When you first create a silverlight project, the size of the silverlight control is automatically set to 100%)
To overcome this we need to do 3 things:
- Remove the Height="100%" attribute from the control in your hosting asp.net page.
- Create a function that determines the height of all the controls within your root panel object.
- Utilize the HtmlElement object to set the height of your ASP.NET silverlight control
Here is how I did it:
private void UpdatePageHeight()
{
double totalHeight = 0;
foreach (RowDefinition rd in ((Grid)(Content)).RowDefinitions)
totalHeight += rd.ActualHeight;
HtmlElement he = HtmlPage.Document.GetElementById("silverlightControl");
he.SetAttribute("height", totalHeight.ToString());
}
Notes:
- I'm using a Grid for my root panel, so I add up the height of all the rows to get my total height.
- I call this function whenever my grid size changes.... seems to cover all cases
No comments:
Post a Comment