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

Posted by John Nicholas on Stack Overflow See other posts from Stack Overflow or by John Nicholas
Published on 2010-11-24T12:10:27Z Indexed on 2010/12/24 17:54 UTC
Read the original article Hit count: 415

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.

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about silverlight-4.0