简体   繁体   中英

Making a StackPanel scrollable in Windows Phone 8

I have a list of controls, put into a stackpanel. These controls are Hubtiles, that are added programatically after a user creates it - a list essentially. I need to make the StackPanel in which they are added, scrollable - what would be the best approach for this? Should i put the stackpanel inside a ScrollView, and then increase the StackPanels height with the actual height of the Hubtile - to make it scrollable, but not so that the user can scroll infinite without something being there. So whenever the amount of controls inside the StackPanel reaches 3, it'll automatically increase it's height like this:

Whenever the amount of controls inside the StackPanel reaches 3 or above:

StackPanel.Height = StackPanel.Height + Hubtile.ActualHeight;

Thanks a lot!

Just put the StackPanel into ScrollViewer , set the StackPanel.VerticalAlignment to Stretch and set fixed size to the parent ScrollViewer. This is necessary - the ScrollViewer must know its size, to show the scrollbars for the inner content when the inner content is too long.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM