这是怎么看我的列表框:WP7 - 显示在列表框中的一些项目按钮,点击后显示更多的内容
<ListBox x:Name="ForthListBox"
Margin="0,0,-12,0"
ItemsSource="{Binding Tops}"
Tap="ForthListBox_Tap" Style="{StaticResource TopListBoxStyle}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17">
<TextBlock Text="{Binding Title}"
TextWrapping="Wrap"
Margin="12,0,0,0"
FontSize="40"/>
<TextBlock Text="{Binding Rating}"
TextWrapping="NoWrap"
Margin="12,-6,0,0"
Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我编辑的列表框模板,所以我在最后有按钮:
<Style x:Key="TopListBoxStyle" TargetType="ListBox">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<ScrollViewer x:Name="ScrollViewer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Padding="{TemplateBinding Padding}">
<StackPanel><ItemsPresenter/>
<Button x:Name="BtnLoadMore" Click="BtnLoadMore_Click" Content="Další" />
</StackPanel>
</ScrollViewer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
并且我在MainViewModel
中有ObservableCollection<Top>()
,我将它绑定到DataContext
。没关系,它显示我的项目,但我怎样才能设置,我想在该列表框中显示50个项目,并且当我点击按钮后,我想从集合中再次显示前50个项目和50个项目,并且一次又一次地在收藏中没有更多项目没有显示,然后隐藏按钮。谢谢
我想,我会收集2本。一个用于绑定,我只是添加我想要显示的项目,第二个将有所有项目,当我点击按钮时从中获得项目,但我认为这个解决方案不是最好的。我希望{Binding}中有一些选项 – 2012-03-26 14:00:52