ScrollViewer的视口高度 VS 实际高度
两者都是非常笼统的术语,但我很想知道除了我们使用虚拟化的情况之外,这些高度何时会有所不同?
还有一个问题: 我在 MSDN 上读到:
如果 CanContentScroll 为 true,则 ExtentHeight、ScrollableHeight、ViewportHeight 和 VerticalOffset 属性的值是项目数。如果 CanContentScroll 为 false,则这些属性的值是设备独立像素。
但是,我遇到了 ViewPort 高度问题:我在应用程序中有 2 个列表框:
1. 启用虚拟化且 CanContentScroll = True。
2. 没有虚拟化并且CanContentScroll = True。
在 ListBox 1 中,拖放视口高度达到 4/5(当前可见的元素数量)。然而,在 ListBox 2 中,我得到的视口高度等于列表框的实际高度。
为什么会有这样的差异?
更多发现:
1.可滚动高度是滚动查看器中不可见的项目数
2. 视口高度是滚动查看器中可见的项目数。
因此 Viewport Height + ScrollableHeight = Extent Height
有人可以解释一下两个列表框之间有什么区别吗?对于列表框 1,我需要 ViewPort 高度
Both are quite general terms but I'm curious to know when these height will be different apart from the case we're using Virtualization?
One more question:
I read on MSDN:
If CanContentScroll is true, the values of the ExtentHeight, ScrollableHeight, ViewportHeight, and VerticalOffset properties are number of items. If CanContentScroll is false, the values of these properties are Device Independent Pixels.
However I'm facing an issue with ViewPort Height: I've 2 listbox in application:
1. Which have Virtualization Enabled and CanContentScroll = True.
2. Which have no virtualization and CanContentScroll = True.
In ListBox 1 while drag-drop Viewport Height comes to 4/5 (Number of elements currently visible). However in ListBox 2 i get Viewport Height equal to Actual Height of Listbox.
Why this difference?
Few more findings:
1. Scrollable Height is number of items not visible in scrollviewer
2. Viewport Height is number of items visible in scrollviewer.
Thus Viewport Height + ScrollableHeight = Extent Height
Can someone please explain what's the difference between two listboxes? I need ViewPort hieght in case of Listbox 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ActualHeight
是 ScrollViewer 的实际高度。视口是从 ScrollViewers 内容中可见的内容。因此,回答您的问题:如果水平滚动条通过滚动条的高度可见,则ViewportHeight
与ActualHeight
不同。所以,总结一下:
the
ActualHeight
is the actual height of the ScrollViewer. The Viewport is what is visible from the ScrollViewers Content. So to answer your question:ViewportHeight
differs fromActualHeight
if the horizontal Scrollbar is visible by theHeight
of the Scrollbar.so, to sum this up:
最后,这是根本原因:
引用 https://stackoverflow.com/a/3062692/3195477:
Finally This was the root cause:
Quoting from https://stackoverflow.com/a/3062692/3195477:
它们可能与(正在进行的)渲染过程中任何给定时间评估的(指定)
Height
点不同。来自 MSDN:
They can differ from the point of (specified)
Height
being evaluated to any given time during the (ongoing) rendering process.From MSDN: