Search code examples
c#wpfxamluser-controlswrappanel

How can I arrange only two items in horizontal in a wrap panel?


I'm using a wrap panel to show several user controls. All of the user controls have a different height and width.

I'd like to arrange the items as maximum 2 items by row, I mean:

| Item1 | Item2 |
| Item3 | Item4 |
| Item5 | Item5 |

I say this becase, when the user expand the window, the items allocate in another positions and it looks like a mess.


Solution

  • Use the UniformGrid it's made for this very purpose

    <UniformGrid Columns="2">
        <!-- Your Controls.. -->
    </UniformGrid>