Making a StackPanel scrollable in Windows Phone 8

﹥>﹥吖頭↗ 提交于 2019-12-22 18:27:05

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/20176799/making-a-stackpanel-scrollable-in-windows-phone-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!