Silverlight:滚动查看器仅在内容溢出时出现?

发布于 2024-10-07 06:04:10 字数 199 浏览 0 评论 0原文

我正在使用 Silverlight 4。我有一个 UserControl,其 LayoutRoot 包装在 ScrollViewer 中。我希望滚动条仅在 LayoutRoot 溢出页面时才出现。可以自动执行此操作,或者我应该编写代码来检测内容是否会溢出并相应地设置滚动条可见性?

I'm using Silverlight 4. I have a UserControl whose LayoutRoot is wrapped in a ScrollViewer. I'd like the scroll bar to only appear if the LayoutRoot overflows the page. It is possible to do it automatically, or should I write code to detect if the content will overflow and set the scrollbar visibility accordingly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九歌凝 2024-10-14 06:04:10

您应该能够使用 <代码>ScrollViewer.Horizo​​ntalScrollBarVisibilityScrollViewer.VerticalScrollBarVisibility 属性。以下是这些属性的所有可能值的列表(< code>ScrollBarVisibility 枚举):

  • 已禁用
  • 自动
  • 隐藏
  • 可见

我认为“自动”就是您正在寻找的:

自动:当视口无法显示所有内容时,会出现 ScrollBar,并将 ScrollViewer 的尺寸应用于内容。对于水平 ScrollBar,内容的宽度设置为 ScrollViewer 的 ViewportWidth。对于垂直 ScrollBar,内容的高度设置为 ScrollViewer 的 ViewportHeight。

希望这有帮助!

You should be able to do it automatically using the ScrollViewer.HorizontalScrollBarVisibility and ScrollViewer.VerticalScrollBarVisibility properties. Here's a list of all possible values for those properties (the ScrollBarVisibility enumeration):

  • Disabled
  • Auto
  • Hidden
  • Visible

I think "Auto" is what you're looking for:

Auto: A ScrollBar appears and the dimension of the ScrollViewer is applied to the content when the viewport cannot display all of the content. For a horizontal ScrollBar, the width of the content is set to the ViewportWidth of the ScrollViewer. For a vertical ScrollBar, the height of the content is set to the ViewportHeight of the ScrollViewer.

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文