水平拉伸 - 组头ListView

时间:2014-10-26 17:47:40

标签: windows-phone-8 winrt-xaml windows-phone-8.1

那么......有什么好主意我们如何在Win RT-phone中的Grouped ListView的GroupHeader模板上启用水平内容拉伸?

我全是耳朵!

我已经添加了一个演示应用程序,您可以尝试一下 - 请在发布答案之前做好! 代码可以在https://github.com/Depechie/ListView-HorizontalStretch-RT81

找到

我添加了2页,MainPage存在没有水平拉伸的问题。 MainPage2有一个修复水平拉伸,但由于该修复,JumpList(缩小视图)不再工作。 您可以通过appbar按钮从MainPage导航到MainPage2。

这里是2个视觉效果

enter image description here enter image description here

2 个答案:

答案 0 :(得分:11)

您的修复程序过于复杂且已弃用。组头标题样式所需的内容如下所示:

<Style x:Key="FixedHeaderContainerStyle"
       TargetType="ListViewBaseHeaderItem">
    <Setter Property="HorizontalContentAlignment"
            Value="Stretch" />
</Style>

并将其应用到ListView中(旧的 ContainerStyle已弃用并替换为HeaderContainerStyle):

<GroupStyle HidesIfEmpty="True"
            HeaderTemplate="{StaticResource AddrBookGroupHeaderTemplate}"
            HeaderContainerStyle="{StaticResource FixedHeaderContainerStyle}" />

但是标头修复并不是ZoomedOutView停止工作的原因。问题是因为您将以下内容添加到MainPage2:

<ListView.ItemsPanel>
    <ItemsPanelTemplate>
        <VirtualizingStackPanel />
    </ItemsPanelTemplate>
</ListView.ItemsPanel>

VirtualizingStackPanel打破了这一点,新的和改进的面板(包括虚拟化是ItemsStackPanel,现在也是默认的,所以完全省略

答案 1 :(得分:0)

如果我了解此问题,请将Width="{Binding ElementName=LayoutRoot, Path=ActualWidth}"添加到主页上的MobileAppsGroupHeaderBorder。这将呈现为像MainPage2一样的全宽,但跳转列表功能保持正常。