水平拉伸 - 组头ListView

Dep*_*hie 4 winrt-xaml windows-phone-8 windows-phone-8.1

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

我全都耳朵!

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

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

这里有2个视觉效果

在此输入图像描述 在此输入图像描述

小智 11

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

<Style x:Key="FixedHeaderContainerStyle"
       TargetType="ListViewBaseHeaderItem">
    <Setter Property="HorizontalContentAlignment"
            Value="Stretch" />
</Style>
Run Code Online (Sandbox Code Playgroud)

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

<GroupStyle HidesIfEmpty="True"
            HeaderTemplate="{StaticResource AddrBookGroupHeaderTemplate}"
            HeaderContainerStyle="{StaticResource FixedHeaderContainerStyle}" />
Run Code Online (Sandbox Code Playgroud)

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

<ListView.ItemsPanel>
    <ItemsPanelTemplate>
        <VirtualizingStackPanel />
    </ItemsPanelTemplate>
</ListView.ItemsPanel>
Run Code Online (Sandbox Code Playgroud)

VirtualizingStackPanel打破了这一点,新的和改进的面板(包括虚拟化是ItemsStackPanel,现在也是默认的,因此完全忽略了这一点).