用于可调整大小的窗口的 WPF 滚动条
这应该是一个非常简单的任务,但由于某种原因我在 WPF 中遇到了很多问题。
这就是我想要发生的事情: 我的窗口中有很多控件,包括扩展器控件。当内容扩展到可见区域下方时,我希望该窗口有滚动条。另外,窗口的宽度不是固定的,它可以最大化、调整大小等。
我尝试将 ScrollViewer 作为窗口中的第一个元素,但它无法正常工作。如果我将高度和宽度设置为“自动”,它不会滚动,如果我将其设置为特定延迟,它会在窗口最大化时创建一个框。
任何帮助将不胜感激!
This should be a very simple task, but for some reason I'm running into a lot of problems with it in WPF.
This is what I want to happen:
I have a bunch of controls in a window, including expander controls. I want to have scroll bars for that window, when content expands below the visible area. Also, the window is not of fixed width, it can be maximized, resized, etc.
I tried putting a ScrollViewer as the first element in the window, but it's not working correctly. If I set the height and width to Auto, it doesn't scroll and if i set it to spefic detentions, it creates a box when the window is maximized.
Any help would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您有一些固定宽度问题。如果您提供 XAML 示例,我可以看看是否可以提供进一步的帮助。以下工作不显示框:
I'm assuming that you have some fixed width issues. If you provide a sample of your XAML I can see if I can help further. The following works without showing a box:
您应该将 ScrollViewer 的 HorizontalScrollBarVisibility 和 VerticalScrollBarVisibility 设置为 Auto。
下面是一个例子:
这替换了VS生成的主窗口的内容。
运行它并更改窗口的大小,将其最大化,您将出现和消失滚动条。
You should set the HorizontalScrollBarVisibility and the VerticalScrollBarVisibility of the ScrollViewer to Auto.
Here is an example:
This replaces the content of the main window generated by VS.
Run it and change the size of the window, maximize it and you'll scroll bars appearing and disappearing.