微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Windows Phone 7 – 如何在LongListSelector中包含ItemsPanel?

我正在使用listBox和wrappanel来显示数据.

例如:

<ListBox ItemTemplate="{StaticResource ItemTemplateListBoxAnimation}">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <toolkit:WrapPanel ItemHeight="150" ItemWidth="150">
                </toolkit:WrapPanel>
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
    </ListBox>

    <DataTemplate x:Key="ItemTemplateListBoxAnimation">
        <Grid Width="130" Height="130">
            <Image Source="{Binding Image}"/>
        </Grid>
    </DataTemplate>

看起来像:

现在我需要使用LongListSelector和分组结果:

<toolkit:LongListSelector ItemTemplate="{StaticResource ItemTemplateListBoxAnimation}">
        <toolkit:LongListSelector.GroupItemsPanel>
            <ItemsPanelTemplate>
                <toolkit:WrapPanel/>
            </ItemsPanelTemplate>
        </toolkit:LongListSelector.GroupItemsPanel>
    </toolkit:LongListSelector>

但它看起来像:

我需要得到:

你的假设?
谢谢

问题是GroupItemsPanel属性不会更改主列表的ItemsPanel,而是更改组标题的ItemsPanel,可以在这里看到(image from http://www.windowsphonegeek.com/articles/wp7-longlistselector-in-depth–part2-data-binding-scenarios):

不幸的是,WP工具包似乎没有暴露出你想要的ItemsPanel,所以你必须修改工具包的源代码才能获得所需的行为.

>从这里获取来源:https://phone.codeplex.com/SourceControl/changeset/view/80797
>解压缩,在Visual Studio中打开Microsoft.Phone.Controls.Toolkit.WP7.sln解决方案.
>在Microsoft.Phone.Controls.Toolkit.WP7项目下,打开主题/ Generic.xaml
>向下滚动到适用于LongListSelector的Style(targettype =“controls:LongListSelector”)
>将TemplatedListBox.ItemsPanel更改为WrapPanel

<primitives:TemplatedListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <controls:WrapPanel/>
                    </ItemsPanelTemplate>
                </primitives:TemplatedListBox.ItemsPanel>

>重建和引用新的dll,您的项目应适当包装!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐