How to get the height of the StackPanel?

How to get the height of the StackPanel?
The height and heightInPixels values ​​give 100% and 0.

I want to place a StackPanel in a ScrollViewer so that the scroll bar appears when the height of the StackPanel exceeds a certain limit. That is, the ScrollViewer would grow along with the StackPanel, but up to a certain limit, then a scroll bar would appear.

Hello :slight_smile:

@RaananW I see that you assigned yourself : What I noticed a few days ago (didn’t report yet) is that real the height is only available after the first render :

console.log("stack_p.heightInPixels", stack_p.heightInPixels);
console.log("stack_p.height", stack_p.height);
setTimeout(function(){
    console.log("stack_p.heightInPixels", stack_p.heightInPixels);
    console.log("stack_p.height", stack_p.height);
},1000)

image
Playground

++
Tricotou

That’s not a bug. It is the same as how we sometimes need to recompute the world matrix of an object after changing its transformation.

What you can do is run your code after the first layout computation:

Simple GUI in fullscreen mode | Babylon.js Playground (babylonjs.com)

This will run after the height was computed, and before render has started.

2 Likes