如何防止 WPF ScrollViewer 在调整内容大小时调整大小?
我有这个 ScrollViewer,我不希望它在内容调整大小时改变大小。
有没有办法防止 ScrollViewer 在其内容控件大小发生变化时调整大小?
更具体地说,在下面的代码中,我不希望 ScrollViewer 变得更大,因为 DockPanel 变得更大。我希望 ScrollViewer 保持不变。
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<DockPanel />
</ScrollViewer>
编辑:
没关系,我想通了。由于某种原因,包含 ScrollViewer 的窗口将 SizeToContent 设置为 WidthAndHeight。将其更改为手动解决了我的问题,即 ScrollViewer 不再调整大小。
I have this ScrollViewer, and I don't want it to change size when its content resizes.
Is there a way to prevent ScrollViewer resizing when its content control size changes?
More specifically, in the following code, I don't want the ScrollViewer to become bigger because the DockPanel got bigger. I want the ScrollViewer to stay the same.
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<DockPanel />
</ScrollViewer>
EDIT:
Nevermind I figured it out. For some reason the Window containing the ScrollViewer had SizeToContent set to WidthAndHeight. Changing it to Manual fixed my problem, i.e. the ScrollViewer doesn't resize anymore.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系,我已经弄清楚了。由于某种原因,包含 ScrollViewer 的窗口将 SizeToContent 设置为 WidthAndHeight。将其更改为手动解决了我的问题,即 ScrollViewer 不再调整大小。
Nevermind I figured it out. For some reason the Window containing the ScrollViewer had SizeToContent set to WidthAndHeight. Changing it to Manual fixed my problem, i.e. the ScrollViewer doesn't resize anymore.