How to get StackPanel height before rendering?

In my software (silverlight 3 application), I create a StackPanel in code, and then add objects to it. Is it possible to get height before rendering? If I try properties like Height or Actual Weight, all zeros ...

Thanks!

+4
source share
2 answers

Have you tried reading DesiredSize ? If it contains 0, try calling Measure , which runs in a Size structure containing large values ​​for Height and Width , then reading DesiredSize .

Please note that DesiredSize does not necessarily mean that the containing element will have it, but I suspect that it will provide you with the information you are after.

+3
source

The panel must be displayed before you can return the height. Then you need to use the ActualHeight property. Height used to set the desired element height.

I do not know anything about prerender elements.

0
source

Source: https://habr.com/ru/post/1299521/


All Articles