gpt4 book ai didi

windows-phone-7 - 如何在 LongListSelector 中包装 ItemsPanel?

转载 作者:行者123 更新时间:2023-12-04 01:07:23 26 4
gpt4 key购买 nike

我正在使用列表框和包装面板来显示数据。

例如:

    <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>

它看起来像:

enter image description here

现在 我需要使用 LongListSelector 和分组结果:
    <toolkit:LongListSelector ItemTemplate="{StaticResource ItemTemplateListBoxAnimation}">
<toolkit:LongListSelector.GroupItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel/>
</ItemsPanelTemplate>
</toolkit:LongListSelector.GroupItemsPanel>
</toolkit:LongListSelector>

但它看起来像:

enter image description here

我需要得到:

enter image description here

你的假设?
谢谢

最佳答案

问题在于GroupItemsPanel属性没有改变 ItemsPanel的主列表,而是 ItemsPanel组标题,如下所示(图片来自 http://www.windowsphonegeek.com/articles/wp7-longlistselector-in-depth--part2-data-binding-scenarios):

group headers wrapped

不幸的是,WP 工具包似乎没有公开 ItemsPanel你想要的,所以你必须修改工具包源以获得你想要的行为。

  • 从这里获取源:https://phone.codeplex.com/SourceControl/changeset/view/80797
  • 解压,在 Visual Studio 中打开 Microsoft.Phone.Controls.Toolkit.WP7.sln 解决方案。
  • 在 Microsoft.Phone.Controls.Toolkit.WP7 项目下,打开 Themes/Generic.xaml
  • 向下滚动到 Style适用于 LongListSelector (TargetType="controls:LongListSelector")
  • 更改 TemplatedListBox.ItemsPanelWrapPanel
                    <primitives:TemplatedListBox.ItemsPanel>
    <ItemsPanelTemplate>
    <controls:WrapPanel/>
    </ItemsPanelTemplate>
    </primitives:TemplatedListBox.ItemsPanel>
  • 重建并引用新的 dll,您的项目应该适本地包装!
  • 关于windows-phone-7 - 如何在 LongListSelector 中包装 ItemsPanel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12341381/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com