tags:

views:

31

answers:

2

Hello! In my software (silverlight 3 application) I create a StackPanel in the code, then add objects to it. Is it possible to get its height before rendering? If I try properties like "Height" or "ActualHeight", it's all zeroes...

Thanks!

A: 

The panel needs to be rendered before you can get the height back. Then you need to use the ActualHeight property. Height is used to set the desired height of the element.

I don't know of any way to "prerender" elements.

ChrisF
+1  A: 

Have you tried reading the DesiredSize? If that contains 0, try calling Measure passing in a Size structure containing large values for Height and Width, then reading the DesiredSize.

Note that the DesiredSize isn't necessarily what the containing element will allow it have but I suspect it will give you the information you are after.

AnthonyWJones