向WPF包装面板添加换行符/换行符 [英] Adding a linebreak/new line to a WPF Wrap Panel
问题描述
有人知道甚至可以在WPF Wrap面板中输入换行符吗?它与包装面板的用途背道而驰,因此我不确定是否可行.
Does anyone know if it's even possible to enter a line break into a WPF Wrap panel? It goes against what the wrap panel is for, so I'm not sure if it's possible.
如果不是,是否还有其他WPF控件实际上允许我在其中输入换行符并支持添加子项(我自己的自定义控件?)
And if it's not, is there any other WPF control that actually allows me to enter a line break into it and supports adding children (my own custom controls?)
推荐答案
这是WrapPanel
中的换行符:
<WrapPanel>
<TextBlock Text="
"/>
</WrapPanel>
更新
我想我已经弄清楚了您要问的问题.如果您有一个WrapPanel
按行布局,并且想将其强制到下一行,则可以将单个WrapPanel
替换为
Update
I think I figured out what you're trying to ask. If you have a WrapPanel
that is laying out by row, and you want to force it to the next row, you can replace the single WrapPanel
with
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<!-- items -->
</StackPanel>
<StackPanel Orientation="Horizontal">
<!-- items -->
</StackPanel>
<StackPanel Orientation="Horizontal">
<!-- items -->
</StackPanel>
</StackPanel>
如果要保留单个行的换行,可以在垂直WrapPanel
.
If you want to preserve wrapping of individual rows, you can use WrapPanel
s inside the vertical StackPanel
.
这篇关于向WPF包装面板添加换行符/换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!