多列滚动、可调整大小的面板?
我有这个:
每个列表都是它自己的 WrapPanel
并且它们都在另一个 < code>WrapPanel 位于 ScrollViewer
中。如果我没有自己为主 WrapPanel
设置高度,它会假设我希望 WrapPanel
尽可能高,只给我一列,而我想要尽可能多的列根据需要填充窗口。
如果我将 WrapPanel
的 Width
和 Height
设置为固定数字,但我希望它在用户调整窗口大小时更改。
I have this:
Each list is its own WrapPanel
and they are all on another WrapPanel
which is in a ScrollViewer
. If I don't set the height myself for the main WrapPanel
it assumes I want the WrapPanel
as high as it can go giving me only one column whereas I want as many columns as needed to fill the window.
If I set the Width
and Height
of the WrapPanel
that holds everything to fixed numbers, but I want it to change when the user resizes the window.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的示例屏幕截图和描述中,我看到一个选项卡控件,其锚点设置为顶部、左侧、底部和右侧。 AutoScroll 设置为 true 的选项卡页。在标签页中我看到一个 FlowLayoutPanel。 FlowLayoutPanel 的 AutoSize 属性设置为 true。我还看到一组其他面板/用户控件,每个面板/用户控件都包含一个标题和一系列复选框。
In your example screen shot and description I see a tab control whose anchor is set to Top, Left, Bottom, and Right. The tab page with AutoScroll set to true. Within the tab page I see a FlowLayoutPanel. The FlowLayoutPanel has its AutoSize property set to true. I also see a set of other panels/user controls each of which contains a title and a series of check boxes.
使用标准控件无法实现这一点。您可以尝试创建自己的自定义 WrapPanel 实现。但实际上,查看原始的 WrapPanel 源代码,我认为这将非常棘手。你看,你想要的基本上是测量当前窗口可以容纳多少列,而列中的每个元素可以是任意大小。在我看来,该算法需要 N*N 次迭代才能获得最终结果。所以你可能会遇到性能问题。
You can`t achieve this with standard controls. You can try to create your own custom WrapPanel implementation. But, actually, looking at original WrapPanel sources I think this will be quite tricky. You see, what you want, is basically to measure how many columns can fit in the current window, while every element in column can be of any size. The way I see that algorithm, it will require N*N iterations to get the final result. So you may have problems with performance.