tags:

views:

21

answers:

2

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.

A: 

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.

DrakeVN
I dont think ViewBox will work in this case, because it tranforms its content, not resize. So you will see things bigger than they are supposed to be.
Euphoric
+2  A: 

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

Nir
Yes, UniformGrid does the trick, but you don't need the Rows=1.
Marius