Hello,
> For example; my stackpanel's
> length is 80 and I want it to be able to display 5 buttons so that
> give a button width of 80/5. I cannot get that 80 at runtime. ActualWidth?..
Seems like the stack panel is not the right choice, as it's not for filling
the whole space with something. It's a grid-like behavior, rather. Will a
grid do instead, star-split for five buttons?
If you'd like to have five or six or else number of buttons, varied at runtime
based on the space available, then the best way is probably to create another
Panel-derived class for that. You'll have two method overrides there, one
for the Measure pass (what'd the desired size of your panel be — a sum of
all the button widths), and the Layout pass. On the latter, you are given
the room available (the length you'd like to get in runtime, that's it),
and you can decide how many buttons fit, and what their locations and widths
should be. If you cannot employ a Grid for that, a custom panel seems like
the best fit.
(H) Serge