向WPF包装面板添加换行符/换行符 [英] Adding a linebreak/new line to a WPF Wrap Panel

查看:394
本文介绍了向WPF包装面板添加换行符/换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道甚至可以在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="&#xD;"/>
</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 WrapPanels inside the vertical StackPanel.

这篇关于向WPF包装面板添加换行符/换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆