HubSection 中的 DataTemplate 没有达到全高 [英] The DataTemplate in HubSection doesn't get full height

查看:19
本文介绍了HubSection 中的 DataTemplate 没有达到全高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

<HubSection x:Name="modules_section" ...>
    <DataTemplate>
        <StackPanel Orientation="Vertical">
        ..................................

如何让 StackPanel 占据 HubSection 的整个高度?

How can I get the StackPanel to take the full height of the HubSection?

VerticalAlignment="Stretch" 不能胜任.

VerticalAlignment="Stretch" doesn't do the job.

我也尝试通过

<StackPanel Height={Binding ElementName=modules_section, Path=ActualHeight}" ...>

但是集线器部分的实际高度似乎是 0(我也尝试在代码隐藏中设置它并调试以查看值).

but the Actualheight of the hub section seems to be 0 (I also tried to set it in code-behind and debugged to see the value).

推荐答案

与其中的内容一样大,但一般来说,要使 与节中剩余空间一样高 就像在节上设置 VerticalContentAlignment 一样简单,即:

A <StackPanel> is as large as the content within it, but in general, to make the items within a <HubSection> as tall as the remainingspace in the section it is as simple as setting the VerticalContentAlignment on the section, i.e:

<HubSection VerticalContentAlignment="Stretch">
    <DataTemplate>
        <ScrollViewer HorizontalScrollMode="..." VerticalScrollMode="...">
            <StackPanel Orientation="Vertical">
                ...

在这种情况下,我将我的 包装在 中以应对有足够数据需要的情况滚动

In this case, I'm wrapping my <StackPanel> in a <ScrollViewer> to cope with when the case with when there is enough data to need to scroll

这篇关于HubSection 中的 DataTemplate 没有达到全高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆