Reputation: 1159
I have a control that inherits from Grid, it is a grid of hexagons that are generated dynamically according to the properties. each of the hexagons is a button and a child of the Grid, and they have a style that displays them as hexagons.
what I want is for the grid to change its size according to the total size of the hexagons. (I can calculate the exact size needed, but I don't know how to set it).
Upvotes: 0
Views: 246
Reputation: 35594
Basically you've got several options. A simple one is calculating the size yourself and assigning to the Grid's Width
and Height
.
A more elaborate solution would be to ask yourself a question: which layout is needed for my items? There are some standard containers which do the layout themselves and can grow/shrink with the content. For example, if your objects are just aligned in a line, you can go for StackPanel
.
Upvotes: 1