简体   繁体   中英

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.

我认为<UniformGrid Rows="1"/>会做你想要的

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM