WPF中的GroupBox只能包含一个元素?
看来 GroupBox 只能包含一个元素,如果我放置多个元素,它就不会进入其中(或在混合中被删除)。
这是设计使然还是我做错了什么?
It seem that GroupBox can only contain one element, if I place more than one it's won't go inside(or get deleted in blend).
Is this by design or am I doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这对我来说听起来不错。您需要将网格或面板(StackPanel、WrapPanel 等)作为子项来定义布局。
That sounds right to me. You'd need to put a Grid or Panel (StackPanel, WrapPanel, etc) as a child to define the layout.
是的,在 WPF 中,GroupBox 最多包含 1 个元素。您可以将 Grid 作为其子项包含在内,并在网格中指定您所需的组件。例如 1 使用 Grid 在 GroupBox 中放置了两个按钮。
文档大纲如下所示:
代码如下:
Yes, in WPF the GroupBox will contain maximum of 1 element. You can include Grid as its child and in grid specify your desired components. For example 1 placed two buttons in GroupBox using Grid.
Document Outline is shown below:
Code is as follow:
好吧,真正的答案是因为 groupbox 继承自 HeaderedContentControl
看看这里
MSDN
Well the real answer is because groupbox inherits from HeaderedContentControl
Take a look here
MSDN
您必须将项目:文本框拖入组框,并且只能有一个组框。每个线性坐标无法拖动多个组框才能正常工作。页面上可以有多个组框,但宽度不能超过单列,否则您将受到限制,只能将单个项目添加到组框中。
You must drag the items: textbox INTO the groupbox and must only have a single groupbox. Cannot drag more than a single groupbox per linear coordinate for it to work. Can have multiple groupboxes on a page, but not more than a single column wide or you will be limited with only having a single item being added to the groupbox.