views:

1334

answers:

2

I want to have my silverlight application to auto size it self to the contents within the application by changing the height of the Host div. How would you get what the size of the total app should be?

For instance I have a Grid with three rows, The top and bottom row have buttons and the middle row has a DataGrid that can change in height based on the page size the user has selected. I want the app to adjust the Host div's height to the height to display the entire app.

A: 

Are you looking for this?

billb
+1  A: 

You've got two options here.

  1. You can manipulate the DOM directly through the HtmlPage property (I would suggest giving the hosting div a unique ID to help you locate it)
  2. Write a javascript function that resizes based on some parameters e.g. function resizeSLHost(width, height). You can then call the javascript function from silverlight and pass it the actual height and width.
ericphan
That's what I've done, but the values that I'm trying to use from the Silverlight Application (i.e. DesiredSize.Height, DesiredSize.Width) and call the javascript function, part of the silverlight app is cut off at the bottom. Right now I'm just trying to adjust the height of the hosting div.
Can you confirm that the javascript function is being called. (e.g. Add an alert that tells your the height and width passed or use firebug)Confirm the parameters seem correct.Try using the ActualHeight property instead, or add some padding to the height in your js function so it shows the whole control
ericphan