Ser*_*lyi 12 xaml wrappanel windows-phone-7 windows-phone longlistselector
我正在使用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>
Run Code Online (Sandbox Code Playgroud)
它看起来像:
现在我需要使用LongListSelector和分组结果:
<toolkit:LongListSelector ItemTemplate="{StaticResource ItemTemplateListBoxAnimation}">
<toolkit:LongListSelector.GroupItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel/>
</ItemsPanelTemplate>
</toolkit:LongListSelector.GroupItemsPanel>
</toolkit:LongListSelector>
Run Code Online (Sandbox Code Playgroud)
但它看起来像:
我需要得到:
你的假设?谢谢
问题是,该GroupItemsPanel
属性不改变ItemsPanel
主列表的,而是ItemsPanel
该组头的,因为在这里可以看到(从图像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项目下,打开Themes/Generic.xaml
向下滚动到Style
适用的目标LongListSelector
(TargetType ="controls:LongListSelector")
更改TemplatedListBox.ItemsPanel
到WrapPanel
<primitives:TemplatedListBox.ItemsPanel>
<ItemsPanelTemplate>
<controls:WrapPanel/>
</ItemsPanelTemplate>
</primitives:TemplatedListBox.ItemsPanel>
Run Code Online (Sandbox Code Playgroud)重建并引用新的dll,你的项目应该适当包装!
归档时间: |
|
查看次数: |
3095 次 |
最近记录: |