简体   繁体   English

wpf:如何水平和均匀地布置项目?

[英]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. 我正在替换树视图模板中的“ItemsPanelTemplate”,并且stackpanel将以正确的方向放置项目,但不会调整它们的大小。 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: 您可以将uniformgrid与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. 请注意ViewBox的StretchMode的不同值,以及统一网格的行中元素的数量。 They depend on your data and how you want to arrange elements. 它们取决于您的数据以及您希望如何排列元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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