Silverlight:如何使用滚动查看器来包装列表视图而不指定高度?
我有一个控件,其列表的长度变化很大。该控件出现在各个地方,这意味着我无法轻松计算其位置和所需的高度。
此外,我想要的只是让滚动查看器根据其父级简单地调整自身大小。目前它坚持根据内容调整自己的规模。
目前,当我有一个超过屏幕高度的列表时,整个控件从底部延伸,并且滚动查看器不显示栏(因为它已拉伸到内容的高度,因此认为不需要)。
我没有包含代码,因为对象图相当深。
我正在寻找的是一组条件,这些条件会导致滚动查看器根据其内容而不是其父级调整自身大小。
我让它在涉及网格和数据网格的类似情况下工作,该控件的独特部分是有一个包含控件的列表。
有什么想法吗?我更喜欢不需要使用后台代码的解决方案 - 但我真的无法挑剔。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是允许滚动查看器根据其内容而不是其“父级”调整大小的常见原因:-
Canvas
或StackPanel
上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":-
Canvas
or aStackPanel
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.