开发者

Silverlight: how to use a scroll viewer to wrap a list view without specifying height?

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开发者_JS百科 a position to be choosey.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜