Marius
Marius

Reputation: 9684

wpf: How do I layout items horizontally and uniformly sized?

What sort of control can layout child items horizontally and also uniformly resize the items to fit the available horizontal space? I'm replacing the "ItemsPanelTemplate" within a treeview template and a stackpanel will lay the items out in the correct orientation, but not resize them. A grid will only show the first child item in the treeview and lacks the support for reoriented horizontally.

Upvotes: 3

Views: 2109

Answers (2)

Nir
Nir

Reputation: 29614

I think just <UniformGrid Rows="1"/> will do what you want

Upvotes: 11

Toan Nguyen
Toan Nguyen

Reputation: 11601

You can use a uniformgrid in conjunction with a viewbox:

For example

<ViewBox StretchMode= "UniformToFill">
    <UniformGrid Cols="5">

    </UniformGrid>

</ViewBox>

Please pay attention to the different values of the StretchMode of the ViewBox, and also the number of element in a row of the uniform grid. They depend on your data and how you want to arrange elements.

Upvotes: 0

Related Questions