开发者

How to get StackPanel height before rendering?

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 rend开发者_如何学Cering? If I try properties like "Height" or "ActualHeight", it's all zeroes...

Thanks!


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜