WPF 网格按钮之间的分隔符
我有一个带有 4 个按钮的网格...1 行,4 列。我正在寻找一种方法来直观地将左侧的两个按钮与右侧的两个按钮分组。我一直在寻找一种使用分隔符来完成此操作的方法,但它似乎与 Grid 配合不佳,更喜欢 StackPanel。
这是正确的控制吗?
如果是这样,如何使该东西分隔列(在本例中用按钮填充)?
谢谢。
I have a grid with 4 buttons...1 row, 4 columns. I am looking for a way to visually group the two buttons on the left from the two on the right. I was looking for a way to do this with a separator but it doesnt seem to be playing nice with Grid, preferring StackPanel.
Is this the right control?
If so, how does one make the thing separate the columns (populated with buttons in this case)?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果其他人偶然发现这个最简单的解决方案:
In case anyone else stumbles across this, easiest solution:
您是否尝试过GridSplitter?
Have you tried a GridSplitter?
我通常使用简单的选择在按钮之间添加一个具有固定宽度的列
您实际上可以使用不同的背景颜色或插入图像
I usually use the simple choice to add a column with a fixed width between the buttons
You can actually use a different background color or insert an image
如果样式正确,则可以使用分隔符。默认情况下,它会创建一条水平线。您必须应用不同的样式才能使其垂直。
请参阅这篇文章,了解如何将其样式设置为 WPF 网格中的垂直线:
CodeProject 讨论
该讨论还提到 StatusBar 对 Separator 元素应用一些样式,只要您不将它们包装在 StatusBarItems 中即可。也许 StackPanel 也做了类似的事情。
You can use Separator if you style it correctly. By default it creates a horizontal line. You have to apply different styling to make it vertical.
See this post for how to style it as a vertical line in a WPF Grid:
CodeProject discussion
The discussion also mentions that StatusBar applies some styling to Separator elements, as long as you don't wrap them in StatusBarItems. Perhaps StackPanel does something similar.