我有以下代码:
<HubSection x:Name="modules_section" ...>
<DataTemplate>
<StackPanel Orientation="Vertical">
..................................
如何让 StackPanel 占据 HubSection 的全部高度?
VerticalAlignment="Stretch"不起作用。
我也尝试使用绑定(bind)通过
<StackPanel Height={Binding ElementName=modules_section, Path=ActualHeight}" ...>
但集线器部分的实际高度似乎为 0(我也尝试在代码隐藏中设置它并调试以查看值)。
最佳答案
一个 <StackPanel>
与其中的内容一样大,但一般来说,使 <HubSection>
中的项目与节中的剩余空间一样高,就像设置 VerticalContentAlignment
一样简单在该部分上,即:
<HubSection VerticalContentAlignment="Stretch">
<DataTemplate>
<ScrollViewer HorizontalScrollMode="..." VerticalScrollMode="...">
<StackPanel Orientation="Vertical">
...
在这种情况下,我将包装我的 <StackPanel>
在 <ScrollViewer>
应对有足够数据需要滚动的情况
关于windows-store-apps - HubSection 中的 DataTemplate 没有得到全高,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22907672/