I have a wrapper panel that will contain a variable number of controls.
I want the orientation to be vertical (since the objects inside have a fixed width but a variable height).
But the problem I ran into is that if there is a scroll bar, the height is inifinite, so the elements never wrap in the second column. A scroll bar is necessary, as there will often be more objects than can be placed on one screen. I can stop this by setting a fixed height, but this is not an acceptable solution, since a reasonable fixed height will be different for each choice.
Essentially, I would like a WrapPanel whose height changes dynamically depending on the width of the panel and the number of elements contained inside.
To illustrate:
If the panel is wide enough to show 3 columns, it will:
| 1 5 9 |
| 2 6 - |
| 3 7 - | Height = 4
| 4 8 - |
But if the user resizes the window to the point where he can only accommodate 2 columns, the height increases:
| 1 6 |
| 2 7 |
| 3 8 | Height = 5
| 4 9 |
| 5 - |
Also, I'm not sure how possible this is, but ideally I would like to arrange the elements horizontally, but keep the orientation vertical, so they will be ordered:
| 1 2 3 |
| 4 5 6 |
| 7 8 9 |
Can someone tell me how to start with this? I assume this is possible with a custom implementation of WrapPanel , but I'm a bit confused how to get started.
Thanks,
source share