如何将 ScrollBar 添加到 Stackpanel
在我的 WPF 应用程序中,我有一个 Stackpanel,其中包含多个控件。如何向此堆栈面板添加滚动条。
In my WPF application, I have a Stackpanel containing several controls inside them. How can I add a Scrollbar to this stackpanel.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
将其放入
ScrollViewer
< /a>.Put it into a
ScrollViewer
.Stackpanel 没有内置滚动机制,但您始终可以将 StackPanel 包装在 ScrollViewer 中
Stackpanel doesn't have built in scrolling mechanism but you can always wrap the StackPanel in a ScrollViewer
它的工作原理如下:
It works like this:
对于水平方向的 StackPanel,显式放置两个滚动条可见性对我来说可以获得水平滚动条。
For horizontally oriented StackPanel, explicitly putting both the scrollbar visibilities worked for me to get the horizontal scrollbar.
如果您的意思是,您想滚动堆栈面板中的多个项目,请尝试在其周围放置网格。根据定义,堆栈面板具有无限长度。
所以尝试这样的事情:
你甚至可以使用 ScrollViewer 来完成这项工作
If you mean, you want to scroll through multiple items in your stackpanel, try putting a grid around it. By definition, a stackpanel has infinite length.
So try something like this:
You could even make this work with a ScrollViewer