Silverlight:如何使用滚动查看器来包装列表视图而不指定高度?

发布于 2024-10-04 22:38:12 字数 359 浏览 1 评论 0原文

我有一个控件,其列表的长度变化很大。该控件出现在各个地方,这意味着我无法轻松计算其位置和所需的高度。

此外,我想要的只是让滚动查看器根据其父级简单地调整自身大小。目前它坚持根据内容调整自己的规模。

目前,当我有一个超过屏幕高度的列表时,整个控件从底部延伸,并且滚动查看器不显示栏(因为它已拉伸到内容的高度,因此认为不需要)。

我没有包含代码,因为对象图相当深。

我正在寻找的是一组条件,这些条件会导致滚动查看器根据其内容而不是其父级调整自身大小。

我让它在涉及网格和数据网格的类似情况下工作,该控件的独特部分是有一个包含控件的列表。

有什么想法吗?我更喜欢不需要使用后台代码的解决方案 - 但我真的无法挑剔。

I have a control that has a list that varies in length greatly. This control appears in various places meaning that i cannot calculate its position and desired height easily.

Moreover all I want is for the scrollviewer to simply size itself according to its parent. currently it insists on sizing itself according to the content.

currently when i have a list that exceeds the height of the screen the whole control extends off the bottom and the scrollviewer shows no bar (because it has stretched to the heigth of the contents and so thinks it is not required).

I've not included code as the object graph is fairly deep.

What i am looking for is a set of conditions that would cause the scrollviewer to resize itself according to its content rather than its parent.

I have it working in a similar situation involving grids and datagrids, the unique part of this control is that there is a list containing controls.

Any ideas? I would prefer solutions that don't require use of code behind - but im really not in a position to be choosey.

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

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

发布评论

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

评论(1

烧了回忆取暖 2024-10-11 22:38:12

以下是允许滚动查看器根据其内容而不是其“父级”调整大小的常见原因:-

  • 它放置在 CanvasStackPanel
  • 它被分配给 Grid 行/列,其水平或垂直对齐方式未设置为“拉伸”,并且其内容大小小于行或列的大小。

最终取决于包含面板如何选择子元素的大小,因此实际上不可能完全从子元素内部的代码来决定这一点。

Here are common reasons that come to mind that would allow a scroll viewer to size to its contents rather than to its "parent":-

  • It's placed on a Canvas or a StackPanel
  • It's assigned to a Grid row/column with it's Horizontal or Vertical alignment not set to Stretch and its content size is less than the size of the row or column.

Its ultimately upto the containing panel how it chooses to size a child element so its not really possible to dictate this completely from code inside the child.

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